Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 Back to the basics! Write a program that asks the user the number of courses he is taking this semester, then asks the

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Exercise 2 Back to the basics! Write a program that asks the user the number of courses he is taking this semester, then asks the user to enter the course codes and grades, and finally prints the average of the grades this semester. No need for input validation in this exercise! Sample run: Enter the number of courses that you are taki Enter the course code for course \#1: COMM1020 Enter the grade obtained in COMM1020: 92 Enter the course code for course \#2: INFS1201 Enter the grade obtained in INFS1201: 78 Enter the course code for course \#3: INFT1201 Enter the grade obtained in INFT1201: 96 Enter the course code for course \#4: MATH1030 Enter the grade obtained in MATH1030: 86 Your average for this semester is: 88.0 Exercise 3 Actually, not all courses have the same weight: the weight depends on the credit value. Modify the previous code to request the credit value of each course and compute the weighted average: the weighted average represents the sum of the grades multiplied by their credit value divided by the sum of all credits. Here is a sample run: Enter the number of courses that you are taking this semester: 4 Enter the course code for course \#1: Comm1020 Enter the number of credits of COMM1020: 3 Enter the grade obtained in COMM1020: 92 Enter the course code for course \#2: INFS1201 Enter the number of credits of INFS1201: 4 Enter the grade obtained in INFS1201: 78 Enter the course code for course \#3: INFT1201 Enter the number of credits of INFT1201: 4 Enter the grade obtained in INFT1201: 96 Enter the course code for course \#4: MATH1030 Enter the number of credits of MATH1030: 3 Enter the grade obtained in MATH1030: 86 Your average for this semester is: 87.85714285714286 Exercise 4 At UDST, the GPA is a weighted average, not of the grades directly but of grade points. Grade points are converted from grades According to the below table: Add to the previous code, a function grade2GP that takes a grade as input and returns the corresponding grade point. Use this function to compute the semester GPA. Here is a sample run: Enter the number of courses that you are taking this semester: 4 Enter the course code for course \#1: ComM1020 Enter the number of credits of COMM1020: 3 Enter the grade obtained in COMM1020: 92 Enter the course code for course \#2: INFS1201 Enter the number of credits of INFS1201: 4 Enter the grade obtained in INFS1201: 78 Enter the course code for course \#3: INFT1201 Enter the number of credits of INFT1201: 4 Enter the grade obtained in INFT1201: 96 Enter the course code for course \#4: MATH1030 Enter the number of credits of MATH1030: 3 Enter the grade obtained in MATH1030: 86 Your semester GPA is: 3.4642857142857144 Part II Exercise 5 With the previous exercises we were able to calculate the semester GPA. To compute the cumulative GPA (the GPA of all semesters) we can either enter all the grades of all courses taken, or simply report the earned credits and credit points at the start of the current semester. This second solution is less tedious so we will adopt it. Ask the user to enter his previous earned credits and credit points then the grades of this semester and finally report the semester GPA as well as the cumulative GPA. Below is a sample run: Enter your current earned credit points: 36.5 Enter your current earned credits: 12 Enter the number of courses that you are taking this semester: 4 Enter the course code for course \#1: COMM1020 Enter the number of credits of COMM1020: 3 Enter the grade obtained in COMM1020: 92 Enter the course code for course \#2: INFS1201 Enter the number of credits of INFS1201: 4 Enter the grade obtained in INFS1201: 78 Enter the course code for course \#3: INFT1201 EnLer Lhe number of credils of INFT1201: 4 Enter the grade obtained in INFT1201: 96 Enter the course code for course \#4: MATH1030 Enter the number of credits of MATH1030: 3 Enter the grade obtained in MATH1030: 86 Your semester GPA is: 3.4642857142857144 Your cumulative GPA is: 3.269230769230769 Exercise 6 It is time to add input validation to make the code more robust: - The current earned credit points should be a float >=0 - The current earned credits should be an integer >=0 - Number ul cuurses this sernester shuuld be ari integer >=0 - Course codes should consist of four letters followed by four digits - Number of credits for each course should be an integer >0 - Grades should be float between 0 and 100. Add all these input validation and test your code. Enter your current earned credit points: two hundred Earned credit points should be a positive number. Enter your current earned credit points: 36.5 Enter your current earned credits: twenty Earned credits should be a positive integer. Enter your current earned credits: 10.5 Earned credits should be a positive integer. Enter your current earned credits: 12 Enter the number of courses that you are taking this semester: 2.5 Number of courses should be a positive integer. Enter the number of courses that you are taking this semester: 4 Enter the course code for course \#1: Comm1020 Enter the number of credits of COMM1020: 3 Enter the grade obtained in COMM1020: 92 Enter the course code for course \#2: INFS Course code should include four letters followed by four digits. Enter the course code for course \#2: 1201 Course code should include four letters followed by four digits. Enter the course code for course \#2: INFS1201 Enter the number of credits of INFS1201: 40.5 Credit of a course should be a positive integer. Enter the number of credits of INFS1201: 4 Enter the grade obtained in INFS1201: 78 Enter the course code for course \#3: INFT1201 Enter the number of credits of INFT1201: 4 Enter the grade obtained in INFT1201: 196 grade should be less than or equal to 100 ! Enter the grade obtained in INFT1201: 96 Enter the course code for course \#4: MATH103 Course code should include four letters followed by four digits. Enter the course code for course \#4: MATH1030 Enter the number of credits of MATH1030: 3 Enter the grade obtained in MATH1030: 86 Your semester GPA is: 3.4642857142857144 Your cumulative GPA is: 3.269230769230769 Exercise 7 As entering all the courses, credits and grades takes time, we will now use a different structure. We assume that we have three lists that contain, the courses names, the credits of each course and the grades in each course. For example, using the same example as we are using so far we would have at the beginning of our code the following three lists: courses=["Past", "COMM1020", "INFS1201", "INFT1201", "MATH1030"] credits =[12,3,4,4,3] grades =[36.5,92,78,96,86] Note that "Past" refers to the credit points and credits earned so far until the previous semester. Based on this structure compute the semester GPA as well as the cumulative GPA. With the same input as above, your code should simply return: Your semester GPA is: 3.4642857142857144 Your cumulative GPA is: 3.269230769230769 Exercise 8 Same exercise as before but with a unique list that contains all the required data: course code, followed by credit, followed by grade. data=["Past", 12, 36.5, "COMM1020", 3, 92, "INFS1201", 4, 78, "INFT1201", 4,96," MATH1030", 3, 86] The sample run should return exactly the same. Your semester GPA is: 3.4642857142857144 Your cumulative GPA is: 3.269230769230769

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago