python-作业2
2017-07-11 21:23
176 查看
#######################################作业##############################3
1,登陆
import time
a = '''
(C)reate:
(L)ogin:
(D)elete:
(V)iew:
input your choice:
'''
while True:
choice = raw_input(a).lower()
dic = {"user1":"123", "user2": "234"}
if choice == 'c':
newuser =raw_input("username:")
newpassword =raw_input("password:")
dic[newuser] = newpassword
print newuser
print "新用户创建成功!"
elif choice == 'l':
user =raw_input("username:")
password =raw_input("password:")
if user in dic and dic[user]==password:
print "登陆成功!"
else:
print "请输入正确的用户名和密码!"
elif choice == 'd':
user =raw_input("username:")
password = raw_input("password:")
if user not in dic:
print "该用户不存在!"
elif dic[user]!= password:
print "密码不正确!"
else:
print "删除成功!"
elif choice == 'v':
user =raw_input("username:")
password =raw_input("password:")
if user not in dic:
print "该用户不存在!"
elif dic[user]!= password:
print "密码不正确!"
else:
print user
print "正常显示!"
else:
print "请重新输入!"
2,购物车
dic = []
salary = input("your salary:")
shopinfo = [
('iphone',1000),
('book',100),
('bike',200)
]
for k,v in enumerate(shopinfo):
print k,v
num = input("num:")
if num == 0:
print "added [iphone] to yourshopping"
if salary < 1000:
print "您的余额不足!"
else:
dic.append('iphone')
elif num == 1:
print "added [book] to yourshopping"
if salary < 100:
print "您的余额不足!"
else:
dic.append('book')
elif num == 2:
print "added [bike] to yourshopping"
if salary < 200:
print "您的余额不足!"
else:
dic.append('bike')
tuichu = input("quit:")
if tuichu == 'q':
quit(shopinfo)
print k,v in enumerate(dic)
#######################################作业##############################3
1,登陆
import time
a = '''
(C)reate:
(L)ogin:
(D)elete:
(V)iew:
input your choice:
'''
while True:
choice = raw_input(a).lower()
dic = {"user1":"123", "user2": "234"}
if choice == 'c':
newuser =raw_input("username:")
newpassword =raw_input("password:")
dic[newuser] = newpassword
print newuser
print "新用户创建成功!"
elif choice == 'l':
user =raw_input("username:")
password =raw_input("password:")
if user in dic and dic[user]==password:
print "登陆成功!"
else:
print "请输入正确的用户名和密码!"
elif choice == 'd':
user =raw_input("username:")
password = raw_input("password:")
if user not in dic:
print "该用户不存在!"
elif dic[user]!= password:
print "密码不正确!"
else:
print "删除成功!"
elif choice == 'v':
user =raw_input("username:")
password =raw_input("password:")
if user not in dic:
print "该用户不存在!"
elif dic[user]!= password:
print "密码不正确!"
else:
print user
print "正常显示!"
else:
print "请重新输入!"
2,购物车
dic = []
salary = input("your salary:")
shopinfo = [
('iphone',1000),
('book',100),
('bike',200)
]
for k,v in enumerate(shopinfo):
print k,v
num = input("num:")
if num == 0:
print "added [iphone] to yourshopping"
if salary < 1000:
print "您的余额不足!"
else:
dic.append('iphone')
elif num == 1:
print "added [book] to yourshopping"
if salary < 100:
print "您的余额不足!"
else:
dic.append('book')
elif num == 2:
print "added [bike] to yourshopping"
if salary < 200:
print "您的余额不足!"
else:
dic.append('bike')
tuichu = input("quit:")
if tuichu == 'q':
quit(shopinfo)
print k,v in enumerate(dic)
相关文章推荐
- Coding the Matrix作业Python Lab及提交方法
- 用Python实现一个细粒度hadoop作业监控分析工具
- An Introduction to Interactive Programming in Python 第六课作业 Blackjack
- Python 显示LinkedIn用户作业
- python基础学习小作业(一)
- Python学习第五周:字符串 - 作业20150611
- An Introduction to Interactive Programming in Python 最后的作业 -- 太空战机
- python__博客网络爬虫作业回顾
- 程序设计入门—Python之第二周作业
- Hadoop运行python作业时的依赖于其他库的问题
- python 教程 第十四章、 地址薄作业
- python小作业初版之信用卡交易
- An Introduction to Interactive Programming in Python 第五课作业 memory
- [Python]这次的Python作业
- python 教程 第十四章、 地址薄作业
- 有效使用Python完成信息论作业
- python 教程 第十四章、 地址薄作业
- python学习:程序控制结构·作业20141219
- logistic回归与牛顿方法的python实现 (standford公开课程小作业)
- 马哥linux+python――2015年8月27日课程作业