这个全是我自己算出来的,感觉很麻烦,求有更简单的代码
#先计算二进制每位是1的情况
s1=[1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63]
s3=[2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63]
s5=[4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31,36,37,38,39,44,45,46,47,52,53,54,55,60,61,62,63]
s7=[8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,40,41,42,43,44,45,46,47,56,57,58,59,60,61,62,63]
s9=[16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63]
s11=[32,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63]
#开始猜测,如果在列表中就输入y不在就n
这个测6次的代码基本一样,感觉非常的单调,希望有人能帮我改改
#开始猜测
print(s1)
num_1=input('在s1里面输入y,不在输入n')
if num_1=='y':
num_1=2**0
else:
num_1=0
print(s3)
num_2=input('在s3里面输入y,不在输入n')
if num_2=='y':
num_2=2**1
else:
num_2=0
print(s5)
num_3=input('在s5里面输入y,不在输入n')
if num_3 =='y':
num_3=2**2
else:
num_3=0
print(s7)
num_4=input('在s7里面输入y,不在输入n')
if num_4 =='y':
num_4=2**3
else:
num_4=0
print(s9)
num_5=input('在s9里面输入y,不在输入n')
if num_5 =='y':
num_5=2**4
else:
num_5=0
print(s11)
num_6=input('在s11里面输入y,不在输入n')
if num_6 =='y':
num_6=2**5
else:
num_6=0
最后再把结果打印出来,只能测0-63
print('让我猜猜是',num_1+num_2+num_3+num_4+num_5+num_6)
新手目前水平只能写这样了