This small program shopping process is:
Start-up welcome, prompt to enter the purchase budget amount, print shopping menu, select goods, products can be repeatedly selected to purchase, when the purchase budget amount is less than the amount of goods purchased, return to the shopping list and prompt budget amount is insufficient.
#!/usr/bin/python# -*- coding:utf-8 -*-shangpin = {' Iphone7 ': 6000, ' mate9 ': 5000, ' MacBook ': 10000, ' note5 ':3000}yusuan = 30000gouwu_list = []print ' = = Welcome to the big cat mall = = ' Print ' ==================== ' Yusuan = int (raw_input (' Please enter purchase Budget amount: ') print ' your budget amount is%d '% Yusuandef shangpin_list (): print ' Product List ' for i in shangpin.items (): print iwhile True: shangpin_list () gouwu = raw_input (' Please enter the name of the product to be purchased: ') gouwu_money = Shangpin[gouwu] if yusuan >= gouwu_money: yusuan -= gouwu_money gouwu_list.append (GOUWU) print ' buy%s successfully! ' % gouwu else: print ' Your budget amount is%d, you can't buy the%s product! ' % (YUSUAN,GOUWU) shangpin_list () print ' Until now, you have now purchased the product%s '% gouwu_list
This article is from the "Just Do Myself" blog, be sure to keep this source http://liubin0505star.blog.51cto.com/5550456/1872595
Python Basic Practice Shopping cart Applet