-
Notifications
You must be signed in to change notification settings - Fork 0
/
pivot.py
186 lines (156 loc) · 5.96 KB
/
pivot.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import os
from datetime import datetime, date
from names import register_voters, all_registered_voters
from user import User
# def calc_time():
# now = datetime.now()
# today = date.today()
# # Time abbreviation, hour min, and second
# current_time = now.strftime("%H:%M:%S")
# # Date abbreviation, day and year
# current_date = today.strftime("%b-%d-%Y")
#
# full_datetime = print("Time and Date =", current_time, current_date)
# creating a dictionary of items to sell in the shop
# The 1 will skip 0 when listing the item number
wands = {'Oak': 23, 'Pine': 99, 'Maple': 837}
# FUNCTIONS
def program_title_bar():
# Clears the terminal screen, and displays a console app title bar.
os.system('clear')
print("****************************************************************")
print("*** You are about to enter another dimension. ***")
print("*** A dimension not only of sight and sound, but of mind. ***")
print("*** A journey into a wondrous land of imagination. ***")
print("****************************************************************")
def store_title_bar():
# Clears the terminal screen, and displays a Store title bar.
os.system('clear')
print("****************************************************************")
print("*** Oleanders Wand Shop ***")
print("****************************************************************")
def riddle_game():
answer = "teeth"
riddle = "Thirty white horses on a red hill, First they champ, Then they stamp, Then they stand still. Which is? "
riddle_guess = input(riddle)
while riddle_guess != answer:
bad_guess = "Guess Again "
riddle_guess = int(input(bad_guess))
print("Impressive! You guessed right.")
def shopping_spree():
purchase = []
print('I hope you love to shop...because you have no other options!')
q1 = input("Do you have any money? ")
if q1 == 'y':
q1_2 = int(input("How much? "))
elif q1 == 'n':
q1_2 = int(input('How much would you like to borrow? '))
print(f"Lets see what you can buy with $ {q1_2}")
store_title_bar()
for i, (k, v) in enumerate(wands.items()):
print(f"[{i+1}] {k} ${v}")
owner_q1 = input('Would you like to buy something? ')
if owner_q1 == 'y':
purchase_number = int(input('Please Enter the Number of the item you would like to buy at this time? '))
purchase.append(purchase_number)
print()
elif owner_q1 == 'n':
print('no')
def nerd_quiz():
# questions dict.items()
nerd_questions = {"What part of the plant conducts photosynthesis? ": "leaf",
"Frog is a reptile or amphibian? ": "amphibian",
"Which scientist proposed the three laws of motion? ": "isaac newton",
"The standard unit of measurement for energy is ____. ": "joule"}
# guesses
nerd_guesses = []
score = 0
for x in nerd_questions.keys():
nerd_guess = input(x)
nerd_guesses.append(nerd_guess.lower())
for x, y in nerd_questions.items():
for i in nerd_guesses:
if i == y:
score += 1
nerd_guesses.pop(0)
break;
print(f'You answered {score} answers correct')
# Open the quiz.txt file in append mode.
quiz_file = open('quiz.txt', 'a')
save_results = input('Would you like to save your results? ')
if save_results == 'y':
# Append the data to the file.
# calc_time()
quiz_file.write(user + ': scored ' + str(score) + ' points : ' + str(current_time) + ' ' + str(current_date) + '\n')
# Close the file.
quiz_file.close()
print('Data appended to quiz.txt.')
def quiz_results():
# Open a file named quiz.txt.
infile = open('quiz.txt', 'r')
# Read the file's contents.
file_contents = infile.read()
# Close the file.
infile.close()
# Print the data that was read into memory
full_quiz_content = print(file_contents)
def user_log():
# Open a file named user_log.txt.
infile = open('user_log.txt', 'r')
# Read the file's contents.
file_user_contents = infile.read()
# Close the file.
infile.close()
# Print the data that was read into memory.
full_user_content = print(file_user_contents)
def get_user_choice():
# This is the main menu
# Let users know what they can do.
print("\n[1] Answer My Riddle")
print("[2] Go Shopping")
print("[3] Take a quiz")
print("[4] Display All Quiz Results")
print("[5] Register to vote")
print("[6] Display All Registerd Voters")
# print("[5] User Quest Tracker")
print("[e] Exit\n")
return input("What would you like to do? ")
# MAIN PROGRAM
# Set up a loop where users can choose what they'd like to do.
users = []
user = input('Please Enter Your Name: ')
users.append(user)
print(users)
choice = ''
program_title_bar()
print(f"\nWelcome, '{user}!")
while choice != 'e':
choice = get_user_choice()
# Respond to the user's choice.
if choice == '1':
riddle_game()
elif choice == '2':
shopping_spree()
elif choice == '3':
nerd_quiz()
elif choice == '4':
quiz_results()
elif choice == '5':
register_voters()
elif choice == '6':
all_registered_voters()
elif choice == 'e':
print("\nSorry.\nBut up can never leave.\nYou live here now.\nGoodBye.")
else:
print("\nI didn't understand that choice.\n")
# This will log users name, selections, and time of section to the user_log.txt file
now = datetime.now()
today = date.today()
# Time abbreviation, hour min, and second
current_time = now.strftime("%H:%M:%S")
# Date abbreviation, day and year
current_date = today.strftime("%b-%d-%Y")
# infile = open('user_log.txt', 'r')
infile = open('user_log.txt', 'a')
infile.write(user + ': selected ' + choice + ' ' + str(current_time) + '\n')
infile.close()