e062: P109 範例9f
Tags : Python
Accepted rate : 0人/0人 (0%) [非即時]
評分方式:
Tolerant

最近更新 : 2024-12-30 15:52

Content

心算測驗。
心算測驗不用準備題庫,只要產生亂數就可以。以下程式,可產生10題1位數心算。

import random 
import time          
r=0
w=0
t1=int(time.time())  
for i in range(10):
    a=random.randint(1,9)
    b=random.randint(1,9)
    c=a+b
    d=int(input('%d :%2d+%2d='% (i+1,a,b)))
    if d==c :
        r=r+1
    else:
        w=w+1
t2=int(time.time())
t=t2-t1
print('The right answer is:%d'% r)
print('The wrong answer is:%d'% w)
print('total time=%d second'% t)

Input
Output
Sample Input #1


											
										
Sample Output #1
1:4+ 4=8
2:7+ 4=11
3:9+ 4=
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (100%): 1.0s , <1K
Hint :
Tags:
Python
出處:
[管理者: zero(育達管理員) ]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」