【每日一练】python算数练习题(函数.随机.判断综合运用)

"""
幼儿园加减法练习题
答对点赞表情,答错炸弹表情
表情随机出现
如果全答对有大奖
"""
import random
df=0
#定义答对函数
def dd():
    global df
    df+=10
    bq=["🌹🌹🌹","🎉🎉🎉","✔✔✔","👍👍👍","🍭🍭🍭"]
    ranbq=random.choice(bq) #使用随机取值的choice()函数
    print(ranbq)

#定义答错函数
def dc():
    bq=["👎","😭","😡","🥀","💣"]
    ranbq=random.choice(bq)
    print(ranbq)

print("幼儿园加减法。(共10题,每题10分)")

t1=int(input("5+6="))
if t1==5+6:
    dd()
else:
    dc()
t2=int(input("5+9="))
if t2==5+9:
    dd()
else:
    dc()
t3=int(input("5+12="))
if t3==5+12:
    dd()
else:
    dc()
t4=int(input("15+4="))
if t4==15+4:
    dd()
else:
    dc()
t5=int(input("1+8="))
if t5==1+8:
    dd()
else:
    dc()
t6=int(input("14+3="))
if t6==14+3:
    dd()
else:
    dc()
t7=int(input("17+3="))
if t7==17+3:
    dd()
else:
    dc()
t8=int(input("13+5="))
if t8==13+5:
    dd()
else:
    dc()
t9=int(input("9+11="))
if t9==9+11:
    dd()
else:
    dc()
t10=int(input("6+12="))
if t10==6+12:
    dd()
else:
    dc()
if df==100:
    print("""
全答对得分:100分
   💖💖💖💖💖💖💖💖💖💖💖
💖💗💗💖💖💖💖💖💓💓💕💕💕💔
🍗🍖🍗🍗🍗🍗🍗🍗🍗
    
    """)

运行结果:

知识点:

  1. 模块的基本导入方法和使用
  2. 函数的基本语法和调用
  3. 使用随机函数随机获取列表元素
  4. 全局变量和局内变量的使用规则,如局内转全局,变量前面要加global 关键字
  5. 以及input,if判断的结合使用

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值