Discover new information and insights with the help of IDNLearn.com. Explore thousands of verified answers from experts and find the solutions you need, no matter the topic.
Sagot :
import random
database = {}
while True:
try:
user_choice = int(input("Enter your student id to bring up your information (Press enter if you don't have one) : "))
user_pass = input("Enter your password: ")
if user_choice in database.keys() and database[user_choice][5] == user_pass:
print("User Authenticated! Welcome, "+database[user_choice][1]+" "+database[user_choice][2])
while True:
choice = int(input("Do you wish to choose your modules, view your selected modules, deposit points, or go back to the main menu? (1,2,3,4): "))
if choice == 1:
modules = input("Choose up to two modules (comma separated): Programming 1, Programming 2, Networking 1, Mathematics ")
modules = modules.split(",")
if len(modules) > 2:
print("You're only allowed to select two modules at one time.")
else:
database[user_choice].append(modules)
elif choice == 2:
if len(database[user_choice]) == 8:
print("Your module(s) are:")
for x in database[user_choice][7]:
print(x.strip())
else:
print("You don't have any modules!")
elif choice == 3:
point_deposit = int(input("How many points would you like to deposit: "))
confirm = input("Do you want to deposit "+str(point_deposit)+" point(s) (y/n): ")
if confirm == "y":
database[user_choice][6] += point_deposit
print("Your point balance is now:",database[user_choice][6])
else:
print("Your deposit could not be confirmed! Deposit denied.")
elif choice == 4:
break
except ValueError:
name = input("Enter your first name: ")
last_name = input("Enter your last name: ")
phone_number = input("Enter your phone number: ")
email = input("Enter your email address: ")
password = input("Enter a password: ")
points = 100
student_id = random.randint(1,1000)
while student_id in database.keys():
student_id = random.randint(1,1000)
print("Hello,",name,"your student ID is:",student_id)
database[student_id] = [student_id,name, last_name, phone_number, email, password, points]
Although I tried to cover all the bases, I might've missed something. I hope this helps.
We appreciate your participation in this forum. Keep exploring, asking questions, and sharing your insights with the community. Together, we can find the best solutions. For precise answers, trust IDNLearn.com. Thank you for visiting, and we look forward to helping you again soon.