My path to Python learning (day1)

Source: Internet
Author: User

has always been not like development, but also more exclusive, so the University of Professional choice of network engineering. But the college does not attach importance to the network, the senior internship when all to training and development only I chose to continue along the network direction go down. It has been working for over a year now, and the needs of traditional network engineers have been very small. In the end, I went back to the development, chose Python, and started my life's new journey.

This is the longest piece of code I've written so far, and there's a lot of imperfections that I want the big guys to guide me a little Beginner

#Author:tannarproduct_list = [     (' Iphone ', 5800),     (' Mac  pro ', 12888),     (' IWatch ', 10600),     (' Bike ', 7777),      (' Python ',,    ) (' Tea ')]shopping_list = []price =  0salary = input ("\033[41;1minput your salary:\033[0m") if salary.isdigit ():     salary = int (Salary)     while True:         for index, item in enumerate (product_list):             print (Index, item)          user_choice = input ("\033[43;1m Select item to buy >>>:\033[0m")          if user_choice.isdigit ():             user_chOice = int (User_choice)             if  user_choice < len (product_list)  and user_choice >= 0:                 p_item = product _list[user_choice]                 if p_item[1] <= salary:                     shopping_list.append (P_item)                      salary  -= p_item[1]                     price += p_item[1]             &nbsP;       print ("\033[45;1madded %s into shopping cart, your current salary is %s\033[0m "% (p_item[0],salary))                  else:                     print ("\033[44;1m your balance is insufficient \033[0m")             else:                 print ("\033[44;1mproduct code is  not exist\033[0m ")         elif user_choice ==   ' Q ':             print ("\033[44; 1m--------------shopping list-----------------\033[0m ")              for p in shopping_list:                 print (P)             print ("The  totally price is  ", Price)              print ("your current balance is ", salary)              exit ()         else:             print ("\033[41;1minvalid input\033[0m") else:     print ("\033[41;1minvalid input\033[0m")


My path to Python learning (day1)

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.