老师要求练习20以内的不进位加法(66张)和6-10的加减法(90张),//5以内的加减法(42张)可以不练,//总共是66+90=156张。
       如下三张图中算式

 

 

 

代码段

#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
import random
import time
from datetime import datetime
import os
os.system('cls')

def m2s(m_str):
    print("m=", m_str[0:1]) #分
    print("s=", m_str[4:6]) #秒
    m = int(m_str[0:1])
    s = int(m_str[4:6])

    conv_seconds = m * 60 + s
    #print(conv_seconds)
    return conv_seconds

def s2m(s_int):
    if s_int > 120:
      #print(s_int/60)
      conv_mins = str(int(s_int/60)) + "mins" + str(s_int%60) + "s"
      return conv_mins

def main():

    # 总算式个数
    total = 0
    math_list = []
    
    # 对应第一幅图
    num = 20
    for a in range(num+1):
        if a > 9:
            for j in range(num - a + 1):
                #print(j)
                #print("%d + %d ="%(j, a))
                math_list.append("%d + %d ="%(j, a))
                total = total + 1
            #print("\n")
    
    # 对应第二幅图
    num = 10
    for a in range(num+1):
        for j in range(num - a + 1):
            #print(j)
            if j > 5 - a:
                #print("%d + %d ="%(j, a))
                math_list.append("%d + %d ="%(j, a))
                total = total + 1
        #print("\n")
    
    #print("======================")
    
    # 对应第三幅图
    num = 10
    for a in range(num+1):
        for j in range(num + 1):
            #print(j)
            if j > 5 and j >= a:
                #print("%d - %d ="%(j, a))
                math_list.append("%d - %d ="%(j, a))
                total = total + 1
        #print("\n")
    
    print("total =", total)
    print("math_list = ", len(math_list))
    
    count = 0
    print("----------------------")
    

    random.shuffle(math_list)
    
    time_begin = datetime.now()
    for k in math_list:
        print(k)
        b = input("")
        if b != '\r':
            #print("Errorrrrrrrrrrrrrrrrrrrrrr")
        #else:
            os.system('cls')
        #s = list2[k]
        #print(s)
        #list2.remove(s)
        #del(k)
        count = count + 1
    print("count = ", count)
    time_end = datetime.now()
    delta_time = (time_end - time_begin).seconds
    print(time_end, time_begin)
    print("total_time =", delta_time)


if __name__ == "__main__":
    main()

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐