书## 级
完成的功能,以便先找到传递给它的三个分数的平均值,并返回与该级别相关联的字母值.
数值评分 | 字母等级 |
---|---|
90 <=评分<= 100 | ‘A’ |
80 <=得分<90 | ‘B’ |
70 <=得分<80 | ‘C’ |
60 <=得分<70 | ‘d’ |
0 <=得分<60 | ‘F’ |
测试值都是0和100之间的Theres不需要检查负值或值大于100.
def get_grade(s1, s2, s3):
# Code here
return "F"
test.describe("grade book")
test.it("should return an A")
test.assert_equals(get_grade(95, 90, 93), "A", "get_grade(95, 90, 93)")
test.assert_equals(get_grade(100, 85, 96), "A", "get_grade(100, 85, 96)")
test.assert_equals(get_grade(92, 93, 94), "A", "get_grade(92, 93, 94)")
test.it("should return a B")
test.assert_equals(get_grade(70, 70, 100), "B", "get_grade(70, 70, 100)")
test.assert_equals(get_grade(82, 85, 87), "B", "get_grade(82, 85, 87)")
test.it("should return a C")
test.assert_equals(get_grade(70, 70, 70), "C", "get_grade(70, 70, 70)")
test.assert_equals(get_grade(75, 70, 79), "C", "get_grade(75, 70, 79)")
test.assert_equals(get_grade(60, 82, 76), "C", "get_grade(60, 82, 76)")
test.it("should return a D")
test.assert_equals(get_grade(65, 70, 59), "D", "get_grade(65, 70, 59)")
点击查看答案
python基础练习题:reverseIt【难度:1级】–景越Python编程实例训练营,不同难度Python习题,适合自学Python的新手进阶
python基础练习题:正弦,余弦及其他【难度:1级】–景越Python编程实例训练营,不同难度Python习题,适合自学Python的新手进阶
python高级练习题:彩色格子点形成了有色三角形【难度:4级】–景越Python编程实例训练营,不同难度Python习题,适合自学Python的新手进阶
python基础练习题:纳特拼音alaphabeta【难度:1级】–景越Python编程实例训练营,不同难度Python习题,适合自学Python的新手进阶
景越Python基础训练营QQ群
欢迎各位同学加群讨论,一起学习,共同成长!
本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars.com/
https://www.codewars.com/kata/grasshopper-grade-book