F01.justanswer.com



BackgroundThe registrar’s database of rooms, students, and courses is stored in three data structures:all_rooms?is a dictionary that contains one pair for each classroom at Wassamatta U. The key is the room’s name (a string); the value is the room’s capacity (an integer).all_courses?is a list in which each element represents one course offered at Wassamatta U. These elements are dictionaries called “course records.” Each course record has five keys, which are always named?course id,?name,?time,?room, and?credits. The corresponding values can be different for each course record. They are:course id: the unique course ID (an integer)name: the full course name (a string)time: the time slot in which the course meets (a string)room: the name of the room in which the course meets (a string)credits: the number of credits for the course (an integer)all_students?is a dictionary that contains one pair for each student enrolled at Wassamatta U. The key is the students’s unique ID number (an integer), and the value is a list of course IDs (integers).It is fine for you to use these data structures in the body of your functions even though they are not passed in as arguments.What You Need to DoHere are the functions you will need to ensure work correctly:total_rooms()This function should return the total number of classrooms at Wassamatta U.?Fortunately, IT was able to recover the code for this function, so you will not need to reimplement it.total_courses()This function should return the total number of courses offered at Wassamatta U.total_students()This function should return the total number of students enrolled at Wassamatta U.room_exists(capacity)This function should return?True?if there is a room with?exactly?this capacity at Wassamatta U. and?False?otherwisestudent_is_enrolled(student_id)This function should return?True?if a student with student ID number?student_id?is enrolled at Wassamatta U, and?False?otherwise.?Fortunately, IT was able to recover the code for this function, so you will not need to reimplement it.course_is_offered(course_name)This function should return?True?if a course with this name is offered at Wassamatta U. and?False?otherwise.biggest_room()This function should return the name of the room with the largest capacity.total_courses(student_id)This function takes as an argument a student ID number. It should return the total number of courses the student with that student ID number is currently enrolled in.total_credits(student_id)This function takes as an argument the student ID number of a student in the dictionary?students. It should return the total number of?credits?for the courses in?courses?the student with that student ID number is currently enrolled in.check_conflict(course_id1, course_id2)This function takes two course ID numbers as arguments. It should return?True?if the courses meet in the same room at the same time, and?Falseotherwise (i.e., if they meet in different rooms or at different times).Note: Two time slots overlap only if and only if they are identical as strings.check_all_conflicts()This function should return?True?if?any?two distinct courses meet in the same room at the same, and?False?otherwise.check_over_capacity(course_id)This function should return?True?if the number of students enrolled in the course with course ID number?course_id?is equal to or less than the capacity of the room in?rooms_list?in which the course meets, and?False?otherwise.Hints: Some of these functions require you to do the same subtasks. We recommend writing them in the order listed. You will find that some of the later functions build on the earlier ones. When you recognize that you are doing something similar to something you have already done, you could:Copy your code from the old function into the new one and make appropriate changes.Call the old function from the new function.Break the repetitive code out into a separate helper function and call that function from both the old and new functions.If you are having trouble getting started, study the two functions whose code you already have (total_rooms()?and?room_exists()). Can you modify them to implement similar functions?Testing your codeTo test your code, you can type?from schedule import *?in the interactive Python interpreter. This will let you try calling functions to see what they do. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download