Question: Please take the work from below and use functions to abstract the code. The goal of this is to make the code more readable and
Please take the work from below and use functions to abstract
the code. The goal of this is to make the code more readable and organized.The new code should run the exact same way as the old code did. If it does, it means the abstraction didnt affect the program, which is the end goal. Code readability and cleanliness are important. Be sure to be smart about using functions and what you abstract and why. A lot of program planning will be useful in doing this successfully. Once you have completed this, I would like you to write approx 1-2 pages where you discuss your technique of abstracting the code. Be sure to discuss your decisions, your process, your struggles, and what you learned overall. Thank you, code below.
#Get the grades homework = float(input("What grade (out of 50) did you receive on the homework? ")) project = float(input("What grade (out of 50) did you receive on the project? ")) quiz = float(input("What grade (out of 40) did you receive on the quizzes? ")) midterm = float(input("What grade (out of 30) did you receive on the midterm? ")) final = float(input("What grade (out of 30) did you receive on the final? ")) #Calculate the total points total = homework + project + quiz + midterm + final max = 200 #Calculate the percentage percent = total / max * 100 #Calculate the grade if percent >= 0 and percent <= 59.99: grade = "F" elif percent >= 60 and percent <= 69.99: grade = "D" elif percent >= 70 and percent <= 79.99: grade = "C" elif percent >= 80 and percent <= 89.99: grade = "B" elif percent >= 90 and percent <= 100: grade = "A" #Print the results print("Your total points: " + str(total)) print("Total possible points: " + str(max)) print("Your Percentage: " + str(percent) + "%") print("Your grade is a " + grade)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
