Amazing-Python-Scripts

Форк
0
/
tarot_card_reader.py 
111 строк · 2.9 Кб
1
import random
2

3

4
# get tarot deck of 78 cards and 'predictions' from tarot.txt
5
file_handle = open("./Tarot Reader/tarot.txt", "r")
6
cards = file_handle.readlines()
7
tarot_deck = []
8
for card in cards:
9
    tarot_deck.append(card)
10

11

12
# Close file, display outro text
13
def fin():
14
    file_handle.close()
15
    print("Whichever your choice was...")
16
    input(">> press enter")
17
    print("May the cards ever be in your favour")
18
    input(">> press enter")
19
    print()
20
    print("\x1B[3mFin\x1B[23m".center(72))
21
    print("*"*72)
22

23

24
# Display when 'Y' or 'y' is entered
25
def youve_chosen_yes():
26
    print("I see that you've chosen to divine your future....")
27
    input(">> press enter")
28
    print("Let's make haste then...")
29
    input(">> press enter")
30
    print("Neither fame nor fortune wait for man")
31
    input(">> press enter")
32
    print()
33
    print("You have drawn three cards")
34
    print()
35
    print("Your first card is...")
36
    pick_card1 = random.randint(0, 77)
37
    print(tarot_deck[pick_card1])
38
    input(">> press enter")
39
    print()
40
    print("Your second card is...")
41
    pick_card2 = random.randint(0, 78)
42
    print(tarot_deck[pick_card2] if pick_card2 !=
43
          pick_card1 else tarot_deck[random.randint(0, 78)])
44
    input(">> press enter")
45
    print()
46
    print("And your third and final card is...")
47
    pick_card3 = random.randint(0, 78)
48
    print(tarot_deck[pick_card3] if pick_card3 != pick_card1 and pick_card3 !=
49
          pick_card2 else tarot_deck[random.randint(0,      78)])
50
    input(">> press enter")
51
    print()
52
    fin()
53

54

55
# Display when 'N' or 'n' is entered
56
def youve_chosen_no():
57
    print("Are you wise...")
58
    input(">> press enter")
59
    print("Or foolish?")
60
    input(">> press enter")
61
    print("I suppose only time will tell")
62
    input(">> press enter")
63
    fin()
64

65

66
# Handles other cases
67
def youve_chosen_neither():
68
    print("*le sigh*")
69
    input(">> press enter")
70
    print("I suppose you think this is a game...")
71
    input(">> press enter")
72
    print("You wouldn't be wrong...")
73
    input(">> press enter")
74
    print("But the only thing that you've played...")
75
    input(">> press enter")
76
    print("Is yourself.")
77
    input(">> press enter")
78
    print("\nNever gonna give you up,\nNever gonna let you down,\nNever gonna run around and desert you.\nNever gonna make you cry,\nNever gonna say goodbye,\nNever gonna tell a lie and hurt you.\n")
79
    fin()
80

81

82
# Intro text
83
print("In this black box, you read white words")
84
input(">> press enter")
85
print("Words that might warn you of danger...")
86
input(">> press enter")
87
print("Words that might foretell great fortune...")
88
input(">> press enter")
89
print("Or words that might make you laugh")
90
input(">> press enter")
91
print()
92

93

94
# Choice made here
95
print("Do you dare draw a card?")
96
ch = input(">> enter Y/n: ")
97
print("\nInteresting...")
98

99

100
# Driver code
101
if ch.lower() == 'y':
102
    print()
103
    youve_chosen_yes()
104

105
elif ch.lower() == 'n':
106
    print()
107
    youve_chosen_no()
108

109
else:
110
    print()
111
    youve_chosen_neither()
112

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.