def GPAcalc(grade, weighted):
grade = grade.lower()
dictionary = {"a": 4, "b": 3, "c": 2, "d": 1, "f": 0}
if weighted == 1 and grade in dictionary:
return "Your GPA score is: "+str(dictionary[grade] + 1)
elif weighted == 0 and grade in dictionary:
return "Your GPA score is : "+str(dictionary[grade])
else:
return "Invalid"
print(GPAcalc(input("Input a letter grade: "), int(input("Is it weigthed? (1= yes, 0= no)"))))
I modified the code a bit to cut down on the use of if and elif statements. If you need me to change it, I will. Best of luck.
The program is an illustration of conditional statements.
Conditional statements are statements whose execution is dependent on its truth value.
The program in Python, where comments are used to explain each line is as follows:
#This initializes the dictionary
dict = {"a": 4, "b": 3, "c": 2, "d": 1, "f": 0}
#This gets input for grade
grade = input().lower()
#This gets input for the weighted average
weighted = int(input())
#If the weighted average is 1, and the grade is in the dictionary
if weighted == 1 and grade in dictionary:
#This prints the GPA score
print("Your GPA score is: "+str(dict[grade] + 1))
#If the weighted average is 0, and the grade is in the dictionary
elif weighted == 0 and grade in dictionary:
#This prints the GPA score
print("Your GPA score is : "+str(dict[grade]))
#Otherwise
else:
#The grade is invalid
print("Invalid")
Read more about similar programs at:
https://brainly.com/question/19241597
DO NOW
1. What are the 4 things that make a computer a
computer?
Answer:
CPU, GPU, Hard drive, Video Card
Explanation:
What are the requirements to access email on the web?
A. a webmail provider's URL and a password
B. a webmail provider's URL a username and a password
C. a credit or debit card, a username, and a password
D. an email server ID and a password
Answer:
it's B
Explanation:
You need to have a provider (such as outlook) and a username/password