30.1k views
4 votes
3.5 Code Practice

Instructions
Input a grade number [9-12] and print Freshman, Sophomore, Junior . or
Senior . If it is not in [9-12], print Not in High School.
Sample Run 1
What grade are you in? 10
Sample Output 1
Sophomore
Sample Run 2
What grade are you in? 5
Sample Output 2
Not in High School
answer in Python​

2 Answers

6 votes

Final answer:

To solve this problem in Python, use an if-elif-else statement to check the input grade number and print the corresponding classification.

Step-by-step explanation:

In Python, you can use an if-elif-else statement to check the input grade number and print the corresponding classification. Here is the code:

grade = int(input('What grade are you in? '))

if grade == 9:
print('Freshman')
elif grade == 10:
print('Sophomore')
elif grade == 11:
print('Junior')
elif grade == 12:
print('Senior')
else:
print('Not in High School')

When the input is 10, the output would be Sophomore. When the input is 5, the output would be Not in High School.

User Farasath
by
5.1k points
3 votes

Answer:

Python.

Step-by-step explanation:

grade_number = input("What grade are you in? ")

/////////////////////////////////////////////////////////////////////

// Using if else control statements to print the right student level

if grade_number == 9:

print("Freshman")

elif grade_number == 10:

print("Sophomore")

elif grade_number == 11:

print("Junior")

elif grade_number == 12:

print("Senior")

else:

print("Not in High School")

User Marcelo Cantos
by
5.0k points