Question 1:
Get input for score out of 100 and evaluate performance:
If the score is less than 35, print "Poor Student".
If the score is greater than 35 but less than 70, print "Average Student".
If the score is greater than 70, print "Good Student".
Program:
# Get input for score out of 100
Score = int(input("Score: "))
if Score < 35:
print("Poor Student")
elif Score >= 35 and Score < 70:
print("Average Student")
elif Score >= 70:
print("Good Student")
else:
print("Invalid Score")
Output Example:
Score: 30
Poor Student
Score: 65
Average Student
Score: 85
Good Student
Program Step-by-Step Explanation:
Step 1: Input the score
- The program asks the user to enter a score between 0 and 100.
Step 2: Check if the score is less than 35
- If the score is less than 35, it prints "Poor Student."
Step 3: Check if the score is between 35 and 70
- If the score is between 35 and 70, it prints "Average Student."
Step 4: Check if the score is 70 or higher
- If the score is 70 or higher, it prints "Good Student."
Step 5: Handle invalid scores
- If the score is not within the expected range (0-100), the program prints "Invalid Score."
Program Step-by-Step Explanation:
Step 1: Input numbers
- The program asks for two numbers (
a
andb
).
Step 2: Input operation
- The user selects an operation (
add
,sub
,mul
, ordiv
).
Step 3: Perform the operation
- Based on the chosen operation:
add
→ Addsa
andb
.sub
→ Subtractsb
froma
.mul
→ Multipliesa
andb
.div
→ Dividesa
byb
.
Step 4: Output result
- The result of the operation is printed.
- If the operation is invalid, an error message is shown.
0 Comments