Define a function that implements the following: ⎻pass in a variable between 0 and 100 called score. ⎻Write an if... else... statement to print a message printing “not in the range,” if the score is not in the range (between 0 and 100). print the grade name indicated in the following table, if the score is between 0 and 100.
时间: 2024-03-16 17:43:27 浏览: 67
kernel的list.h(分享)
5星 · 资源好评率100%
Sure, here's a Python function that meets your requirements:
```python
def print_grade(score):
if score < 0 or score > 100:
print("not in the range")
elif score >= 90:
print("A")
elif score >= 80:
print("B")
elif score >= 70:
print("C")
elif score >= 60:
print("D")
else:
print("F")
```
You can call this function with a score between 0 and 100 as an argument, and it will print the corresponding grade based on the table you provided. If the score is outside that range, it will print "not in the range" instead.
阅读全文