How can I 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?
Answers
Answered by
3
Answer:
9-12 freshman this correct answers
Answered by
10
Python program for the above :
Explanation:
List1={9:'Freshman',10:'Sophomore',11:'Junior',12:'Senior'}#dictonary which holds the predefined key and the grades.
value=int(input("Enter the number from 9 to 12: "))#take the valuse for grade number.
if value in List1:#if condition which checks the key in the list.
print(List1[value])
else:
print("Not in High School")#print for match not found.
Output :
- If the user input as "9", it will prints "Freshman".
- If the user input as "13". It will prints "Not in High School".
Code Explanation :
- The above code is written in python language, which has a list of predefined values.
- The program checks the number entered by the user to be present in the list or not. If it is then print the grade otherwise print the above question demands.
Learn More:
- Python : https://brainly.in/question/14689905
Similar questions