python 作业
来源:互联网 发布:知识产权投诉淘宝处罚 编辑:程序博客网 时间:2024/05/05 12:02
作业:创建一个简单的雇员姓名和编号的程序,让用户输入一组雇员姓名和编号,你的程序可以提供姓名排序输入的功能,雇员姓名显示在前面,后面的是对应的雇员编号。附加题:添加一项功能,按照雇员编号的顺序输出数据。
#coding:utf-8
dict1={}
dict2={}
def add():
i=0
count=input("please input the number of employee:")
while i<count:
name=raw_input("please input the name of employee:")
if name=="--":
break
number=raw_input("please input the number of employee:")
if number==" ":
break
dict1[name]=number
dict2[number]=name
i+=1
xuanze()
def xuanze():
print '''
1.add the data
2.sort with name
3.sort with number
4.quit '''
choose=raw_input("please choose a number:")
if choose == "1":
add()
elif choose == "2":
for key in sorted(dict1):
print key,dict1[key]
elif choose == "4":
quit
else:
print "error"
pass
if __name__ == '__main__':
xuanze
结果:
0 0
- python 作业
- Python作业
- python作业
- python作业
- Python作业
- python作业
- Python 作业
- python课后作业1
- python作业1
- Python学习day3作业
- Python学习day4作业
- Python学习day5作业
- Python自学 第二次作业
- Python自学 第一次作业
- python笔记及作业
- python作业1
- python作业2
- python作业12
- JAVA
- Win10上Python3通过pip安装时出现UnicodeDecodeError
- centos7上部署php+mysql+nginx
- ubuntu password
- 腾讯2016实习招聘-安全岗笔试题答案详细解释
- python 作业
- 搜罗的关于Lua协程的几个示例
- 在Docker中的ubuntu中安装python和pip
- 蓝桥杯模拟赛排列序数
- 欢迎使用CSDN-markdown编辑器
- 删除链表中倒数第n个节点
- python1
- 小李的银行存款以及保留小数位方法
- Java 接口和抽象类区别