728x90
반응형
이 코드는 사용자는 자신의 이름을 묻고 개인화된 운세가 생성되어 화면에 표시됩니다.
운세는 5가지를 넣었습니다.
import random
# List of pre-determined fortunes
fortunes = [
"A beautiful, successful, and fulfilling future awaits you.",
"You will soon meet someone new and special.",
"You will receive good news and financial gains soon.",
"Travel and new experiences are in your future.",
"You will find love and happiness in the near future."
]
# Welcome message
print("Welcome to the Fortune Teller!")
# Ask for user's name
name = input("What is your name? ")
# Generate a random fortune
fortune = random.choice(fortunes)
# Print the fortune
print("\nHello, " + name + "! Your fortune is:")
print("\n" + fortune + "\n")
728x90
반응형
'코딩' 카테고리의 다른 글
마텔에서 만든 Magic 8 Ball 장난감을 파이썬으로 구현해보자. (0) | 2023.02.17 |
---|---|
코딩할 때 가장 흔히 저지르는 5가지 실수에 대해 알아보겠습니다. (0) | 2023.02.17 |
취업할 때 알면 좋은 파이썬 지식 10가지 모음 (0) | 2023.02.11 |
파이썬으로 로또 번호를 크롤링하는 코드를 만들어 보겠습니다. (0) | 2023.02.11 |
pyautogui를 활용하여 hello world 자동화를 해보자. (0) | 2023.02.08 |
댓글