Python Foundation One

Source: Internet
Author: User

Shopping Cart

1List = ["Headset"," Book","MP3","Camare","Condom","Alienware","Iphone7"]2Price = [800,60,300,5000,34,20000,6000]3Basket = []4Salary ="1"5  whileType (Salary)! = Type (1):6     Try:7salary = Int (input ("Please input your salary:"))8     except:9         Print("Please enter number!")Ten  whileTrue: One     Print("You can buy the following things:") A      forIinchRange (1,len (list) +1): -         PrintI". ", List[i-1],'\ t', price[i-1]) -      whileTrue: theChoice = input ("Please enter the serial number of the item want: ' Q ' is exit!") -         ifChoice = ="Q": -             Print("You bought something below:",'\ n', Basket,'\ n',"Your balance:", salary,'\ n',"byebye!") - exit () +         Try: -Choice =int (choice) +         except: A             Print("wrong type!") at             Continue -         ifChoice < 1orChoice >7 : -             Print("wrong number!") -             Continue -         Else: -Price_choice = price[choice-1] in             ifPrice_choice >Salary: -differ = Price_choice-Salary to                 Print("Sorry,you ' re worse than", differ) +             Else : -Salary = salary-Price_choice theBasket.append (list[choice-1]) *                 Print("You got the", list[choice-1]) $                 Print("Your balance:", salary)

Python Foundation One

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: 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.