Python双色球系统

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/YiHong_Li/article/details/81144413
import random

print('游戏开始'.center(50, "*"))
cardMoney = int(input("请为您的彩票卡充值(金额 > 2元):"))
while True:
	if cardMoney > 1:
		break
	else:
		cardMoney = int(input("请重新输入充值金额:"))
while True:
	buyLottery = input("是否购买彩票?【yes/no】")
	while True:
		if buyLottery == 'yes' or buyLottery == 'no':
			break
		else:
			buyLottery = input("输入有误!请重新输入...【yes/no】")
	if buyLottery == 'yes':
		lotteryNum = input('请输入所购买的彩票的序列号(6位数字,只含0和1):')
		while True:
			for x in lotteryNum:
				if len(lotteryNum) == 6:
					pass
				else:
					lotteryNum = input('输入位数有误!请重新输入...:')
				if x == '0' or x == '1':
					pass
				else:
					lotteryNum = input('输入数字有误!请重新输入...:')
			break
		cardMoney -= 2
		print('购买彩票需要2元!您的余额还有cardMoney =', cardMoney)
		lotteryStr = ''
		for x in range(6):
			lotteryStr += random.choice(['0', '1'])
		print('您购买的彩票号码为:', lotteryNum)
		print('开奖号码为:', lotteryStr)
		if lotteryNum == lotteryStr:
			cardMoney += 200
			print("恭喜您中了200元大奖!!!您的彩票卡余额还有cardMoney =", cardMoney)
		else:
			print("很遗憾没中奖,继续努力!")
			if cardMoney > 1:
				print("您的彩票卡余额还有cardMoney =", cardMoney)
			else:
				print('您的彩票卡余额不足,还剩cardMoney =', cardMoney)
				charge = input('是否为您的彩票卡充值?【yes/no】')
				while True:
					if charge == 'yes' or charge == 'no':
						break
					else:
						charge = input("输入有误!请重新输入...【yes/no】")
				if charge == 'yes':
					chargeMoney = int(input('请输入充值金额:'))
					while True:
						if chargeMoney > 1:
							cardMoney += chargeMoney
							break
						else:
							chargeMoney = int(input("请重新输入充值金额:"))
							print("充值成功!您的彩票卡余额还有cardMoney =", cardMoney)
				else:
					print('谢谢您的参与,欢迎下次再来!')
					print("您的彩票卡余额还有cardMoney =", cardMoney)
					break
	else:
		print('谢谢您的参与,欢迎下次再来!')
		print("您的彩票卡余额还有cardMoney =", cardMoney)
		break
print('游戏结束'.center(50, "*"))

 

展开阅读全文

没有更多推荐了,返回首页