Python作业之购物商城
作业:购物商场
1、商品展示,价格
2、银行卡余额
3、付账
程序流程图如下:

代码如下:
ShopDisplay = {'clothes1':'','jeans':'','shoes':'','hat':'','clothes2':''}
print(ShopDisplay)
ShoppingCartPrice = []
ShoppingCart = {}
while True:
thing = input("You want to buy :")
price = ShopDisplay['%s' %thing]
ShoppingCart.update({ '%s' %thing:'%s' %price })
ShoppingCartPrice.append('%s' % price)
answer = input("Do you want to continue buy something else?Please say yes or no:")
if answer == 'yes':
continue
else:
break
def shit():
sum = 0
TotalMoney = 1000
for i in ShoppingCartPrice:
sum = sum + int(i)
TotalMoney = TotalMoney - sum
if TotalMoney > 0:
a = input("Do you really want to buy tins ?Please enter yes or no !\n")
if a == 'yes':
print("Successful,wish you a happy shopping!\n")
exit()
else:
print("Thanks you for come to my shop!")
exit()
else:
print("Sorry,you have not enough money!Please remove somethings!\n")
sum = 0
TotalMoney = 1000
for i in ShoppingCartPrice:
sum = sum + int(i)
TotalMoney = TotalMoney - sum
if TotalMoney > 0 :
a = input("Do you really want to buy tins ?Please enter yes or no !\n")
if a == 'yes':
print("Successful,wish you a happy shopping!\n")
exit()
else :
exit()
else :
print("Sorry,you have not enough money!Please remove somethings!\n")
while True:
print("Your shopping cart have this thing:\n")
print(ShoppingCart)
print("If you don't want to del,please enter '.'\n")
del_thing = input("Please input the goods that you don't want to buy:\n")
if del_thing == '.':
break
s = ShoppingCart['%s' % del_thing]
ShoppingCart.pop('%s' % del_thing)
ShoppingCartPrice.remove(s)
shit()
代码很简陋,作业功能基本都实现了,将就着看吧。。。。日后再来优化
Python作业之购物商城的更多相关文章
- Day2作业:购物商城
ReadMe: 注意事项: 1.本程序需要提前安装prettytable模块,在商品展示时使用了prettytable 2.数据库使用json模块,有中文数据,在mac系统上编写,运行没有出现问题,在 ...
- python 信用卡系统+购物商城见解
通过完成信用卡系统+购物商城 使自己在利用 字典和列表方面有了较大的提升,感悟很深, 下面将我对此次作业所展示的重点列表如下: #!/usr/bin/env python3.5 # -*-coding ...
- Python实现ATM+购物商城
需求: 模拟实现一个ATM + 购物商城程序 额度 15000或自定义 实现购物商城,买东西加入 购物车,调用信用卡接口结账 可以提现,手续费5% 每月22号出账单,每月10号为还款日,过期未还,按欠 ...
- python采用sqlachmy购物商城
一.流程图: 二.目录结构: C:\USERS\DAISY\PYCHARMPROJECTS\S12\MARKET │ __init__.py │ __init__.pyc │ ├─backend │ ...
- Python小练习-购物商城(一部分代码,基于python2.7.5)
新手写作,用来练习与提高python编写.思考能力,有错误的地方请指正,谢谢! 第一次写博客,课题是一位大神的博客,本着练习的目的,就自己重写了一遍,有很多不足的地方,希望借博客记录下自己的成长: ...
- day2编写购物商城(1)
作业:购物商城 商品展示,价格 买,加入购物车 付款,钱不够 具体实现了如下功能: 1.可购买的商品信息显示 2.显示购物车内的商品信息.数量.总金额 3.购物车内的商品数量进行增加.减少和商 ...
- day2编写购物商城
作业:购物商城 商品展示,价格 买,加入购物车 付款,钱不够 流程图如下: 代码共有4个文件,如下: 用户文件: alex geng zhang lou zeng 商品文件: 小米3 比亚迪宋 格力变 ...
- day2、购物商城
作业:购物商城 商品展示,价格 买,加入购物车 付款,钱不够 代码如下: import codecs #登录接口,用户名密码都正确登录成功,否则失败 def login(your_name,your_ ...
- python day19 : 购物商城作业,进程与多线程
目录 python day 19 1. 购物商城作业要求 2. 多进程 2.1 简述多进程 2.2 multiprocessing模块,创建多进程程序 2.3 if name=='main'的说明 2 ...
随机推荐
- 定时任务-Quartz
Quartz Quartz w3c教程 参考:https://blog.csdn.net/lkl_csdn/article/details/73613033 Quartz 的使用 https://ww ...
- msp430入门学习40
msp430的其他八 msp430入门学习
- SQL Server 命令行操作
连接sqlcmd -S localhost -U SA -P '123456'; 执行脚本 sqlcmd -S localhost -U SA -P '123456' -i /root/dbo.sql ...
- LeetCode OJ--Remove Duplicates from Sorted List II *
http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ 处理链表的范例 #include <iostream ...
- 迁移桌面程序到MS Store(8)——通过APPX下载Win32Component
在上一篇<迁移桌面程序到MS Store(7)——APPX + Service>中,我们提到将desktop application拆分成UI Client+Service两部分.其中UI ...
- Ubuntu 16.04安装微信
微信没有出Linux的版本,但是可以通过以下方式解决: 1.使用网页版,除了没有公众号之后,一切都没问题,包括传文件等. 网页登录地址:https://wx.qq.com/ 2.使用第三方版本,只不过 ...
- 框架-数据库定义MD5加密
1.--定义Md5加密declare @pt_pwd varchar(50)set @pt_pwd = ''set @pt_pwd = substring(sys.fn_sqlvarbasetostr ...
- iOS Application Security
文章分A,B,C,D 4个部分. A) iOS Application Security 下面介绍iOS应用安全,如何分析和动态修改app. 1)iOS Application security Pa ...
- 如何在ASP.NET Core自定义中间件中读取Request.Body和Response.Body的内容?
原文:如何在ASP.NET Core自定义中间件中读取Request.Body和Response.Body的内容? 文章名称: 如何在ASP.NET Core自定义中间件读取Request.Body和 ...
- scapy在wlan中的应用
Scapy 又是scapy,这是python的一个网络编程方面的库,它在wlan中也有很强大的应用.一般我们买块网卡,然后aircrack-ng套件爆破一下邻居的密码,其实我们可以用scapy写一些有 ...