728x90
반응형
이 코드는 클래식 Magic 8 Ball 장난감의 디지털 버전을 만드는 데 사용할 수 있습니다. 사용자는 질문을 입력할 수 있으며 프로그램은 미리 결정된 여러 답변 중 하나를 무작위로 생성합니다.
import random
# List of pre-determined answers
answers = [
"It is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."
]
# Welcome message
print("Welcome to the Magic 8 Ball Game!")
# Ask for user's question
question = input("What is your question? ")
# Generate a random answer
answer = random.choice(answers)
# Print the answer
print("\nThe Magic 8 Ball says:")
print("\n" + answer + "\n")
감사합니다. 열심히 할게요.
728x90
반응형
'코딩' 카테고리의 다른 글
빅오표기법 알고리즘 문제 (0) | 2023.03.16 |
---|---|
Ubuntu 20.04 한글 안될 때 한영키 설정하기 (0) | 2023.03.03 |
코딩할 때 가장 흔히 저지르는 5가지 실수에 대해 알아보겠습니다. (0) | 2023.02.17 |
랜덤으로 운명을 점쳐주는 운세게임 코드를 만들어보자. (0) | 2023.02.16 |
취업할 때 알면 좋은 파이썬 지식 10가지 모음 (0) | 2023.02.11 |
댓글