shopping card

keypoints:

1:define a list as shopping list

2: list operation :enumerate

3:the  conception

weakness:

without any fuction used .

#!/usr/bin/python
# -*- coding: utf-8 -*-
print (‘welcome to shopping mall‘)
print (‘%-5s  %-10s  %-10s‘  %(‘p_id‘,‘gname‘,‘price‘))
pro_list=[(‘apple‘,10),(‘pair‘,20),(‘orange‘,30),(‘banana‘,40)]
for index,i in enumerate(pro_list):
        print (‘%-5s  %-10s  %-10s‘ % (index+1,i[0],i[1]))
total = input(‘please input your recharge :‘)
shopping_card=[]
flag = ture
while flag:
        num = input (‘please select menu: input num | shopping(s) |quit(q) |check(c)|pay(p) :‘)
        if num == s :
            num1=input (‘please input what you want to buy:‘)
            if num1.isdigit() is false:
                print (‘invalid,please re-fill‘)
            if num1<len(pro_list) and num1>0:
                shopping_card = shopping_card.append(pro_list[num1])
            else:
                print (‘ your input is incorrect‘)
        elif num == c :
            amount = 0
            for index , s in enumerate(shopping_card):
                print (‘index, s[0],s[1]‘)
        elif num == p :
            amount = 0
            for goods in pay_cart:
                amount+=goods[1]
                conf = input(‘complete payment: Y‘)
                if conf == y :
                   left = total - amount
                   if left >0 :
                      pay_cart = shopping_card
                      shopping_card=[]
                      total = left
                      print (‘shopping_lists%  Cost_moneys%‘ % (pay_cart,amount))
                   else :
                        print (‘not enough moeny‘)
        elif num==q:
            if shopping_cart:
                print (‘you are shopping,do you want quit, Y ‘)
                qu = input(‘quit : y | shopping : N‘)
                if qu == y:
                        flag = false
                else :
                        print (‘enjoy your shopping‘)
            else:
                flag = false
                print(‘thanks for your shopping‘)
时间: 2024-10-17 19:44:05

shopping card的相关文章

(原创)北美信用卡(Credit Card)个人使用心得与总结(个人理财版) [精华]

http://forum.chasedream.com/thread-766972-1-1.html 本人2010年 8月F1 二度来美,现在credit score 在724-728之间浮动,最高的时候也就730,属于good range, 大于746的才算excellent score.两年之内从没有信用记录到Good,觉得还算不错,现在把自己如何build credit history和一些心得与大家分享.希望对大家有帮助. 信用记录在北美的重要性自然不必多说.我的启蒙是校内/renren

sdio card休眠处理 sdio card removed解决办法

最近调试几款sdio card suspend时都会出现sdio card removed,之后 要么死机要么模块不能正常工作,根本原因也就是休眠没有处理好. 昨天在博通网卡上终于找到了解决方法. 1:host端需要设置nonremovable,软件设置:mmc->caps |= MMC_CAP_NONREMOVABLE; 2:host端需要设置keep power,在sdio card suspend时 软件设 置:host->pm_flags | = MMC_PM_KEEP_POWER:

UESTC 31 饭卡(Card) --背包问题

背包问题. 思路:如果m<5,此时也不能消费,所以此时答案为m m>=5: 求出背包容量为m-5,买前n-1样便宜的菜(排个序)的最大价值(即最大消费,即消费完后剩余值最接近5)最后减去最大的那个菜的价格,就得到最小的余额. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using n

hdu 4336 Card Collector

Card Collector http://acm.hdu.edu.cn/showproblem.php?pid=4336 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Special Judge Problem Description In your childhood, do you crazy for collecting the beautiful cards in

Using Android Phone to recover SD card formatted with DD command under linux

1. Formatted a sd card with dd command under linux 2.insert the sd card into an android phone,certainly the card is not find and used.. 3 reset the android phone with format sd card option. 4.the sd card is ok!

Secrets To Getting Amazon gift card codes To Complete Tasks Quickly And Efficiently

Amazon gift card are not as easy to get if you do not know how to complet a survey . Amazon gift card are difficult and as hard to combact with the survey . So please do not hurry you should try the new method to get free amazon gift card codes . For

Shopping Offers

Shopping Offers 在商店中,每一种商品都有一个价格(用整数表示).例如,一朵花的价格是 2 zorkmids (z),而一个花瓶的价格是 5z .为了吸引更多的顾客,商店举行了促销活动. 促销活动把一个或多个商品组合起来降价销售,例如: 三朵花的价格是 5z 而不是 6z, 两个花瓶和一朵花的价格是 10z 而不是 12z. 编写一个程序,计算顾客购买一定商品的花费,尽量利用优惠使花费最少.尽管有时候添加其他商品可以获得更少的花费,但是你不能这么做. 对于上面的商品信息,购买三朵花

Identity Card(水题)

Identity Card Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2696    Accepted Submission(s): 1048 Problem Description Do you own an ID card?You must have a identity card number in your family'

hdu 5159 Card (期望)

Problem Description There are x cards on the desk, they are numbered from 1 to x. The score of the card which is numbered i(1<=i<=x) is i. Every round BieBie picks one card out of the x cards,then puts it back. He does the same operation for b round