Assignment 4: Student Schedule Instructions In this assignment, you will draw a student schedule by using a while loop. You will ask the user for their first and last names, and then a list of their classes and room numbers. The loop should stop when the user enters STOP for their next class. The schedule should print in the same format as the sample below. Some tips for formatting are: Use spaces, not tabs, when printing the lines that contain only two asterisks to ensure that it is aligned with the lines containing nothing but asterisks. Use tabs, not spaces, between certain items to help align the strings and variables as shown in the sample. You should end up with 3 tabs on each of these lines.
Answers
Student Schedule Instructions
Explanation:
Python program
first_name = input('Enter your first name: ')
last_name = input('Enter your last: ')
classes = []
while True:
class_name = input('Enter a name of the (next) class (or STOP/Stop/stop): ')
if class_name not in ['STOP', 'Stop', 'stop']:
room_number = input('Enter a room number of the class: ')
classes.append((class_name, room_number))
else:
break
if classes:
print('\n'+first_name, last_name + '\'s schedule:')
print('-------------------------')
print('Class\t\tRoom')
print('-------------------------')
for num, (class_name, room_number) in list(enumerate(classes, start=1)):
print(str(num)+'.'+class_name, '\t', room_number)
Output
Enter your first name: Binni
Enter your last: Verma
Enter a name of the (next) class (or STOP/Stop/stop): Thursday
Enter a room number of the class: 121
Enter a name of the (next) class (or STOP/Stop/stop): Monday
Enter a room number of the class: 112
Enter a name of the (next) class (or STOP/Stop/stop): Wednesday
Enter a room number of the class: 23
Enter a name of the (next) class (or STOP/Stop/stop): stop
Binni Verma's schedule:
-------------------------
Class Room
-------------------------
1.Thursday 121
2.Monday 112
3.Wednesday 23