python-列表练习程序ver1
来源:互联网 发布:剑三dx11笔记本优化版 编辑:程序博客网 时间:2024/06/05 09:45
列表练习
1、让用户输入工资
2、输出购物菜单及产品价格
3、计算用户是否可支付
4、输出用户剩余的钱,问用户是否继续购物,如果选择继续,继续进行,只到钱不够为止
5、如若不够,提示用户剩余工资不够购买,并推出程序
root@kali:~/python# cat listsalary.py
#!/usr/bin/python
# --*-- coding:utf-8 --*--
while True:
salary = int(raw_input('please input your salary:')) #
print ' -------shopping list---------'
print '''
old car 5000$
iphone7s 799$
knife 39$
book 12$
'''
print ' -----------------------------'
print 'your salary is % s$'% salary
list1 = ['old car','5000']
list2 = ['iphone7s','799']
list3 = ['knife','39']
list4 = ['book','12']
select_number = 0
print '-------------------------------------------------------------------------------------'
print 'you can buy %d old car,free_salary is %d$,please select 1' %(salary/5000,salary%5000)
print 'you can buy %d iphone7s,free_salary is %d$,please select 2' %(salary/799,salary%799)
print 'you can buy %d knife,free_salary is %d$,please select 3 ' %(salary/39,salary%39)
print 'you can buy %d book,free_salary is %d$,please select 4' %(salary/12,salary%12)
print '-------------------------------------------------------------------------------------'
while True:
select_number = int(raw_input('please select number:'))
free_salary = 0
if select_number == 1:
print 'you buy %d old car '% int(free_salary/5000)
print 'now your salary is %d$ '% int(free_salary%5000)
free_salary = int(salary%5000)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
print 'now your free_salary is %d$,you can buy follow lists.'% free_salary
print 'you can buy %d old car,free_salary is %d$,please select 1-4 exit!' %(free_salary/5000,free_salary%5000)
print 'you can buy %d iphone7s,free_salary is %d$,please select 1-4 exit!' %(free_salary/799,free_salary%799)
print 'you can buy %d knife,free_salary is %d$,please select 1-4 exit! ' %(free_salary/39,free_salary%39)
print 'you can buy %d book,free_salary is %d$,please select 1-4 exit!' %(free_salary/12,free_salary%12)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
select_number = int(raw_input('please select number:'))
if free_salary <= 11:
print 'you donot have salary ,you donot buy anything!'
exit()
if free_salary <=38 and free_salary>=12:
print 'you can buy %d book ,please select 4' % int(free_salary/12)
exit()
if free_salary <=798 and free_salary>=38:
print 'you can buy %d knife ,please select 3 ' % int(free_salary/39)
exit()
if free_salary <=4999 and free_salary>=799:
print 'you can buy %d iphone7s ,please select 2' % int(free_salary/799)
exit()
if select_number == 2:
print 'you buy %d iphone7s '% int(free_salary/799)
print 'now your salary is %d$ '% int(free_salary%799)
free_salary = int(salary%799)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
print 'now your free_salary is %d$,you can buy follow lists.'% free_salary
print 'you can buy %d iphone7s,free_salary is %d$,please select 1-4 exit!' %(free_salary/799,free_salary%799)
print 'you can buy %d knife,free_salary is %d$,please select 1-4 exit! ' %(free_salary/39,free_salary%39)
print 'you can buy %d book,free_salary is %d$,please select 1-4 exit!' %(free_salary/12,free_salary%12)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
select_number = int(raw_input('please select number:'))
if free_salary <= 11:
print 'you donot have salary ,you donot buy anything!'
exit()
if free_salary <=38 and free_salary>=12:
print 'you can buy %d book ,please select 4' % int(free_salary/12)
exit()
if free_salary <=798 and free_salary>=38:
print 'you can buy %d knife ,please select 3 ' % int(free_salary/39)
exit()
if select_number == 3:
print 'you buy %d knife '% int(free_salary/39)
print 'now your salary is %d$ '% int(free_salary%39)
free_salary = int(salary%39)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
print 'now your free_salary is %d$,you can buy follow lists.'% free_salary
print 'you can buy %d knife,free_salary is %d$,please select 1-4 exit! ' %(free_salary/39,free_salary%39)
print 'you can buy %d book,free_salary is %d$,please select 1-4 exit!' %(free_salary/12,free_salary%12)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
select_number = int(raw_input('please select number:'))
if free_salary <= 11:
print 'you donot have salary ,you donot buy anything!'
exit()
if free_salary <=38 and free_salary>=12:
print 'you can buy %d book ,please select 4' % int(free_salary/12)
exit()
if select_number == 4:
print 'you buy %d book '% int(free_salary/12)
print 'now your salary is %d$ '% int(free_salary%12)
free_salary = int(salary%12)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
print 'now your free_salary is %d$,you can buy follow lists.'% free_salary
print 'you can buy %d book,free_salary is %d$,please select 1-4 exit!' %(free_salary/12,free_salary%12)
print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
select_number = int(raw_input('please select number:'))
if free_salary <= 11:
print 'you donot have salary ,you donot buy anything!'
exit()
root@kali:~/python#
- python-列表练习程序ver1
- python-列表练习程序ver2
- python-列表练习程序ver3
- python列表小练习
- python之列表练习
- python练习小程序
- python小程序练习
- python核心编程7.5答案ver1
- Python练习程序(二)文件处理和列表元组
- Python练习代码 -- 元组,列表,字典
- python tkinter练习小程序
- 列表练习
- 列表练习
- python学习之小的练习程序
- Python 练习册,每天一个小程序
- Python 练习册,每天一个小程序
- Python 练习册,每天一个小程序
- 第24个python程序:更多练习
- Cloudera manager install
- 马踏过河卒(niop2002,经典递推)
- windows 环境下使用ultraedit远程编辑linux文件
- [BZOJ 3052][wc2013]糖果公园:树上带修改莫队
- Linux获取系统时间函数 ---->localtime
- python-列表练习程序ver1
- docker-compose
- 使用正则解决Js、JQuery replace 只替换第一个的问题
- C++期末考试题
- Zookeeper WINDOWS 安装配置
- 如何对Scala中集合进行排序
- android 调用系统相机、相册剪切功能
- Vue 2.0 构建单页应用最佳实战
- A380 URAL