A: Guess
Guessing game:
1. The system generates a random number from 1 to 100;
2. a total of five opportunities to guess a user;
3. If the user guessed number is greater than the system gives a digital printing "TOO Big"
4. If the number is less than the user guesses given digital system, print "TOO Small"
5. the digital If the user guesses a number equal to the given system, print "Congratulations winning"
and exit the loop
a = random.randint(1,100)
i=1
for i in range(1,6):
player = int(input("请输入你要输入的数字:"))
if (player < a):
print("too small")
print('你还有%d次机会' % (5 - i))
elif (player > a):
print("too big")
print('你还有%d次机会' %(5-i))
else:
print("恭喜,你猜对了!!!")
print('你要猜的数字是%d' %a )
break
else:
print("失败,请再接再砺!!!")
print('你要猜的数字是%d' %a)
Two: do multiplication problems
while True:
import random
a = random.randint(0,10)
b = random.randint(0,10)
print('你要做的题目是%d * %d:' %(a,b))
d = int(a * b)
c = int(input("请输入你的答案:"))
if c==d:
print("你的答案是正确的!")
else:
print("你的答案是错误的!")
If you do while true:
three: Print a multiplication table
row = 1
while row <= 9:
col = 1
while col <= row:
print('*d * %d = %d \t' %(col,row,row*col),end='')
col += 1
print('')
row += 1