python二级练习(6)

栏目: Python · 发布时间: 8年前

内容简介:python二级练习(6)

6. 从键盘接收一百分制成绩(0~100),要求输出其对应的成绩等级A~E。其中,90分以上为'A',80~89分为'B',70~79分为'C',60~69分为'D',60分以下为'E'。

#python 3.6
#蔡军生 
#http://blog.csdn.net/caimouse/article/details/51749579
#

dictionary = {90:'A', 80:'B', 70:'C', 60:'D', 0: 'E'}

score = int(input('请输入成绩(0~100):'))
if score > 100 or score < 0:
    print('输入错误成绩')
else:
    for key in sorted(dictionary.keys(),  reverse = True):
        if score >= key:
            print('成绩为', dictionary[key])
            break

输出结果:

========== RESTART: D:/work/example/py_ex_006.py ==========

请输入成绩(0~100):60

成绩为 E

>>> 

========== RESTART: D:/work/example/py_ex_006.py ==========

请输入成绩(0~100):70

成绩为 C

>>> 

========== RESTART: D:/work/example/py_ex_006.py ==========

请输入成绩(0~100):1010

输入错误成绩

>>> 

深入浅出Matplotlib

https://edu.csdn.net/course/detail/6859

深入浅出Numpy

http://edu.csdn.net/course/detail/6149

Python游戏开发入门


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Advanced Web Metrics with Google Analytics

Advanced Web Metrics with Google Analytics

Brian Clifton / Sybex / 2008 / USD 39.99

Are you getting the most out of your website? Google insider and web metrics expert Brian Clifton reveals the information you need to get a true picture of your site's impact and stay competitive usin......一起来看看 《Advanced Web Metrics with Google Analytics》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具