Get the most out of your questions with IDNLearn.com's extensive resources. Join our interactive Q&A community and get reliable, detailed answers from experienced professionals across a variety of topics.

2) Module selection and verification:
The program must authenticate the student access using student ID and password.

Students should be able to choose two different modules out of the following modules (more than two modules is not possible):
Programming 1
Programming 2
Networking 1
Mathematics

Students should be able to view their current selected modules.

The program should allow the user to return to the main page.

3) Student account top-up:
The program must authenticate the student access using student ID and password.

Students should be able to deposit points in his/her point account. The program should confirm the requested points with the user before adding them into his/her account.

The program must return to the main page.


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.