hi,我是复仇流浪者,我今天给大家带来一个不一样的项目,
因为这是一个应用哦;
好了不废话,直接上代码!
import random import time right_times = 0 wrong_times = 0 while True: a = random.randint(1, 10) b = random.randint(1, 10) operator = random.randint(1, 4) if operator == 1: print(a , "+" , b , "=") result = a + b if operator == 2: if a >= b: print(a , "-" , b , "=") result = a - b else: print(b , "-" , a , "=") result = b - a if operator == 3: print(a , "*" , b , "=") result = a * b if operator == 4: print(b * a , "/" , b ,"=") result = b * a / b begin_time = time.time() your_answer = int(input("请输入你的答案:")) end_time = time.time() used_time = end_time - begin_time if your_answer == result: if used_time > 10: print(" 超时了!50分!") print("用时为" , used_time) print("------------------------------") print() wrong_times += 1 else: print(" 答对了!100分!") print("用时为" , used_time) print("------------------------------") print() right_times += 1 else: print(" 答错了! 0分!") print("------------------------------") print() wrong_times += 1 if right_times == 10: print("!王.666.计算小能手.666.者!") print(''' ___________________________ | | | | | | | /\ /\ | / (^) (^) \ / \ / o \ | | \ / \ \ / / | \ / | \ \ / / \ \__/ / |______________________| ''') break if wrong_times == 5: print("~加.come.再接再厉.on.油~") print(''' ___________________________ | | | | | ____ ____ | | /\ /\ | / (0) (0) \ / \/ \/ \ / * o * \ | * * | \ * * / \ * * / | * /\ * | \ * / \ * / \ * / \ * / |______________________| ''') break
这个应用还挺好用的,我还会更新另一个《计算小能手》哦,
拜拜!
本站作者已申明原创,禁止转载!
文章内容属作者个人观点,不代表本站立场,如有侵权立删。