1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # LAB 7-4 ¿À´ÃÀÇ ¸í¾ðÀ» °ñ¶óÁÖ´Â ±â´ÉÀ» ¸¸µéÀÚ, 187ÂÊ # import random express = [] express.append("1 + 2") express.append("341 - 154") express.append("514 * 516") express.append("516 / 4") express.append("5151 + 1541") express.append("65411 - 65156") express.append("12345679 * 81") express.append("142857 * 7") express.append("10761 - 9999") express.append("1577 - 1577") print("############################") print("# ¿À´ÃÀÇ ¼öÇй®Á¦ #") print("############################") print("") dailyQuiz = random.choice(express) print(dailyQuiz, '=', eval(dailyQuiz)) | cs |
Ãß°¡ 1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import random express = ["1 + 2","341 - 154","514 * 516","516 / 4","5151 + 1541", "65411 - 65156","12345679 * 81","142857 * 7","10761 - 9999","1577 - 1577"] print("############################") print("# ¿À´ÃÀÇ ¼öÇй®Á¦ #") print("############################") print("") dailyQuiz = random.choice(express) solution = eval(dailyQuiz) while (True) : print(dailyQuiz, '= ', end="") answer = int(input()) if answer == solution : print("Àß ¸ÂÃß¾ú½À´Ï´Ù.") break else : print("Ʋ·È½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇϼ¼¿ä.") | cs |
Ãß°¡ 2)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import random express = ["1 + 2","341 - 154","514 * 516","516 / 4","5151 + 1541", "65411 - 65156","12345679 * 81","142857 * 7","10761 - 9999","1577 - 1577"] print("############################") print("# ¿À´ÃÀÇ ¼öÇй®Á¦ #") print("############################") print("") while (True) : dailyQuiz = random.choice(express) solution = eval(dailyQuiz) while (True) : print(dailyQuiz, '= ', end="") answer = int(input()) if answer == solution : print("Àß ¸ÂÃß¾ú½À´Ï´Ù.") break else : print("Ʋ·È½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇϼ¼¿ä.") print("¶Ç ÇϽðڽÀ´Ï±î? (yes/no):",end='') answer_continue = input() if answer_continue == "yes" : continue; else : break | cs |