본문 바로가기

Python_Matter/Solve

magic 8 ball Game 코드

반응형

Q>

magic 8 ball game 코드를 작성하시오.

 

A>

import random

ans1 = "turquoise Summit"
ans2 = "Account Wooden redundant"
ans3 = "impactful"
ans4 = "Plastic programming fuchsia"
ans5 = "compelling"
ans6 = "tan invoice Curve"
ans7 = "Guilder"
ans8 = "Developer"

name = input("What you'r name\n")

print("{0}! Hello, MyMagic8Ball Game!\n".format(name))

question = input("For advice, just type in a question and hit enter?\n")

print("In trouble...\n" * 4)

choice = random.randint(1, 8)

if choice == 1:
    answer = ans1
elif choice == 2:
    answer = ans2
elif choice == 3:
    answer = ans3
elif choice == 4:
    answer = ans4
elif choice == 5:
    answer = ans5
elif choice == 6:
    answer = ans6
elif choice == 7:
    answer = ans7
else:
    answer = ans8

print(answer)

input("\n\nenter is end game")
반응형

'Python_Matter > Solve' 카테고리의 다른 글

1 ~ 100 까지 세는 코드  (0) 2021.05.08
구구단 5단 출력 코드  (0) 2021.05.08
2 ~ 20 까지 세는 코드  (0) 2021.05.08
Python Learn the basics Quiz 113  (0) 2019.07.03
Python Learn the basics Quiz 112  (0) 2019.07.02