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游戏开发入门


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

查看所有标签

猜你喜欢:

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

Agile Web Development with Rails 4

Agile Web Development with Rails 4

Sam Ruby、Dave Thomas、David Heinemeier Hansson / Pragmatic Bookshelf / 2013-10-11 / USD 43.95

Ruby on Rails helps you produce high-quality, beautiful-looking web applications quickly. You concentrate on creating the application, and Rails takes care of the details. Tens of thousands of deve......一起来看看 《Agile Web Development with Rails 4》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

html转js在线工具
html转js在线工具

html转js在线工具