![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/6453d708b3470b1baa6d348956358d65.png)
这个是34题的内容。我理解不了就改成 了用循环的方式随机出数和计算机随机出数进行比较。结果输多。根本赢不了,程序如下,先上结果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ae1779e2cdbb8288092e7717a6ba9d98.png)
看到了吗最后输很多次
我设计的题如下,祝大家玩的开心
# 5.34
import random
count_win = 0
count_win_draw = 0
count_lose = 0
count_draw = 0
for guess in range(0, 100):
lottery = random.randint(0, 99)
lotteryDigit1 = lottery // 10
lotteryDigit2 = lottery % 10
guessDigit1 = guess // 10
guessDigit2 = guess % 10
print("The lottery number is", lottery)
if guess == lottery:
print("Exact match: you win $10,000")
count_win += 1
elif (guessDigit2 == lotteryDigit1 and
guessDigit1 == lotteryDigit2):
print("Match all digits: you win $ 3,000")
count_win_draw += 1
elif (guessDigit1 == lotteryDigit2
or guessDigit2 == lotteryDigit1
or guessDigit2 == lotteryDigit2):
print("Match one digit: you win $1,000")
count_draw += 1
else:
print("Sorry, no match")
count_lose += 1
print(f"This lottery match win {count_win}")
print(f"This lottery match draw {count_draw}")
print(f"This lottery match lose {count_lose}")
print(
f"This match last money{(count_win * 10000) + (count_win_draw * 3000) + (count_draw * 1000) - (count_lose * 1500)}")