# Ask the user how many credits they have taken
credits = input("Enter the number of credits you have taken: ")
# Check if the input is a valid number
if credits.isdigit():
credits = int(credits)
# Print the class year based on the number of credits
if credits <= 23:
print("You are a freshman.")
elif credits <= 53:
print("You are a sophomore.")
elif credits <= 83:
print("You are a junior.")
else:
print("You are a senior.")
else:
print("Invalid input. Please enter a positive integer.")
12, the program will print You are a freshman., and if the user enters 70, the program will print You are a junior..The output of the program would depend on what the user enters as input. Here are some example outputs:
Input: 12
Output: You are a freshman.
Input: 30
Output: You are a sophomore.
Input: 70
Output: You are a junior.
Input: 100
Output: You are a senior.
Input: abc
Output: Invalid input. Please enter a positive integer.

0 Comments