Untitled
unknown
plain_text
2 years ago
2.1 kB
10
Indexable
import random subjects = [ "Math", "Phy", "Chem", "Comp", "Eng", "Games", ] time_slots = [ ("08:10 AM", "09:10 AM"), ("09:10 AM", "10:10 AM"), ("10:10 AM", "10:30 AM"), ("10:30 AM", "11:30 AM"), ("11:30 AM", "12:30 PM"), ("12:30 PM", "01:00 PM"), ("01:00 PM", "02:00 PM"), ("02:00 PM", "03:00 PM"), ] weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] class_section = input("Enter the section: ") timetables = {weekday: {} for weekday in weekdays} assigned_subjects = {weekday: [] for weekday in weekdays} for weekday in weekdays: subjects_copy = subjects.copy() for time_slot, (start_time, end_time) in enumerate(time_slots, start=1): if (start_time == "10:10 AM" and end_time == "10:30 AM"): activity = "Break" elif start_time == "12:30 PM" and end_time == "01:00 PM": activity = "Lunch" else: available_subjects = [s for s in subjects_copy if s not in assigned_subjects[weekday]] if available_subjects: activity = random.choice(available_subjects) assigned_subjects[weekday].append(activity) else: activity = "No Subject Available" timetable_entry = f"{start_time} - {end_time}" timetables[weekday][timetable_entry] = activity # Display the timetable in a formatted table with aligned columns print(f"Timetable for Class 12{class_section}:\n") print(" | Time | Monday | Tuesday | Wednesday | Thursday | Friday |") print("-------------------------------------------------------------------------------------------------------------------") for time_slot, (start_time, end_time) in enumerate(time_slots, start=1): print(f"{time_slot:<2} | {start_time.ljust(0)} - {end_time.ljust(0)} |", end="") for weekday in weekdays: activity = timetables[weekday].get(f"{start_time} - {end_time}", "") activity = activity.ljust(15) print(f"{activity} |", end=" ") print()
Editor is loading...