212k views
1 vote
Need some help writing a simple PYTHON Student registration program:

Students must enter their information including name, last name, phone number, email address and create a password.

By default, the program must assign a unique student ID between 1 to 1000.

The program should allocate 100 points to each registered student account automatically (students can use these points for shopping)

The system must print the allocated student ID on the screen (Student uses his/her ID for access to the rest of system functions)

The program must return to the main page.

1 Answer

4 votes

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) : "))

if user_choice in database:

print("Student ID:",database[user_choice][0],"\\First name:",database[user_choice][1],"\\Last name:",database[user_choice][2],"\\Phone number:",database[user_choice][3],"\\Email address:",database[user_choice][4],"\\Password:",database[user_choice][5],"\\Points:",database[user_choice][6])

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:

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]

I wrote my code in python 3.8. I hope this helps.

User Manzini
by
4.4k points