Python Basic Practice Shopping cart Applet

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.