zoukankan      html  css  js  c++  java
  • 计应193第一组小学生做题软件——姚则谦

    小学生算术能力测试系统:
    设计一个程序,用来实现帮助小学生进行百以内的算术练习,它具有以下功能:
    提供10道加、减、乘或除四种基本算术运算的题目;
    练习者根据显示的题目输入自己的答案,程序自动判断输入的答案是否正确并显示出相应的信

    import random
    def calculation_formula(a,b,c,c1,c2):
        if c1 == '+':
            num = a+b
        else:
            num = a-b
        if c2 == '+':
            num = num+c
        else :
            num = num-c
        return num
      
    def random_formula():
        a = random.randint(0, 100)
        b = random.randint(0, 100)
        c = random.randint(0, 100)
        op = ['+', '-']
        c1 = random.choice(op)
        c2 = random.choice(op)
        formula = str(a) + c1 + str(b) + c2 + str(c)
        re = calculation_formula(a,b,c,c1,c2)
        string = formula+'='+str(re)
        if re < 0:
            random_formula()
        else:
            with open(r'C:Userslch20Desktopmath1.txt','a',encoding='utf-8') as f:
                f.write(string)
                f.write('
    ')
            pass
     
     
    for i in range(25):
        random_formula()
        pass

    息。

  • 相关阅读:
    解释器
    桥接
    组合
    hbase读性能优化
    Hbase为什么写比读快
    http和https区别
    R apply() 函数和 tapply() 函数
    R 语言 decostand() 函数
    R多行交叉作图
    k-mean 拐点
  • 原文地址:https://www.cnblogs.com/bladepoint/p/14829143.html
Copyright © 2011-2022 走看看