Write a python program that prompts the user to enter the GPA and displays a message…
- User
Write a python program that prompts the user to enter the GPA and displays a message showing the letter GPA and whether this student is accepted in the MSc. Program based on the following criteria. If the student has a GPA >=3.0, then he/she will be admitted. If the student has a GPA>2.5, then he/she will be admitted with probation. Otherwise, he/she will not be allowed to join the program.
- Assistant
gpa = float(input("Enter your GPA: ")) if gpa >= 3.0: print("Congratulations! You have been accepted into the MSc. Program.") elif gpa > 2.5: print("Congratulations! You have been admitted into the MSc. Program with probation.") else: print("Sorry, you are not allowed to join the MSc. Program.")Explanation:
-
The user is prompted to enter their GPA using the
input()function. The result is stored in the variablegpa, which is converted to a floating-point number usingfloat(). -
The first condition
if gpa >= 3.0:checks if the GPA is greater than or equal to 3.0. If true, it prints a congratulatory message stating that the student has been accepted into the MSc. Program. -
The
elif gpa > 2.5:condition checks if the GPA is greater than 2.5, which means it is less than 3.0. If true, it prints a message stating that the student has been admitted into the MSc. Program with probation. -
If both the previous conditions are false, then the
elseblock executes and prints a message stating that the student is not allowed to join the MSc. Program.
-