MUstar

IoT Python3 0816 - 매일매일Py 두뇌트레이닝

Aug 16th, 2017
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. import time
  3.  
  4. def make_question():
  5.     a = random.randint(1, 40)
  6.     b = random.randint(1, 20)
  7.     op = random.randint(1, 3)
  8.  
  9.     q = str(a)
  10.  
  11.     if op == 1:
  12.         q = q +"+"
  13.     if op == 2:
  14.         q = q +"-"
  15.     if op == 3:
  16.         q = q+"*"
  17.  
  18.     q = q + str(b)
  19.  
  20.     return q
  21. def clear():
  22.     print("\n" * 100)
  23.  
  24. clear()
  25. print("======매일매일Py 두뇌트레이닝======")
  26. input("=====PRESS ANT KEY 2 START=====")
  27. clear()
  28. print("=3=");time.sleep(1);clear()
  29. print("=2=");time.sleep(1);clear()
  30. print("=1=");time.sleep(1);clear()
  31. print("Go~");time.sleep(1);clear()
  32.  
  33. start = time.time()
  34. sc1 = 0
  35. sc2 = 0
  36.  
  37. for x in range(10):
  38.     q = make_question()
  39.     print(q)
  40.     ans = input("=")
  41.     r = int(ans)
  42.  
  43.     clear()
  44.     if eval(q) == r:
  45.         print("정답!")
  46.         sc1 = sc1 + 1
  47.     else:
  48.         print("오답!")
  49.         sc2 = sc2 + 1
  50.  
  51. end = time.time()
  52. et = float(round(end-start,2))
  53. clear()
  54. if sc2 == 0:
  55.     if et <=10:
  56.         print("두뇌나이 10대초반")
  57.     elif et <=13:
  58.         print("두뇌나이 10대후반")
  59.     elif et <=15:
  60.         print("두뇌나이 20대초반")
  61.     elif et <=18:
  62.         print("두뇌나이 20대후반")
  63.     else:
  64.         print("두뇌나이 측정불가!")
  65. else:
  66.     print("정답:", sc1, "오답:", sc2)
  67.     print("[매일매일Py 두뇌트레이닝]을 합시다")
  68. print("총계산시간:",  et)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×