日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python 的 购物小程序

發布時間:2023/12/20 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 的 购物小程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 money = input('請輸入您的工資:') 2 shop = [("iphone",5800),("ipod",3000),("book",210),("Archer python",80)] 3 while not money.isdigit(): 4 print("請正確輸入整數",end=':') 5 money = input() 6 money = int(money) 7 while True: 8 print("商品詳情".center(50,'-')) 9 for i in range(len(shop)): 10 print("%d. %s $%s".center(50,' ') % (i,shop[i][0],shop[i][1])) 11 print("請輸入你要購買的商品序號,(退出請按'q'):",end='') 12 num = input() 13 while not( num == 'q' or num.isdigit() and int(num) < len(shop) and int(num) >= 0 ): 14 print("請正確輸入商品序號:",end='') 15 num = input() 16 if num == 'q': 17 break 18 num = int(num) 19 if money >= int(shop[num][1]): 20 money -= int(shop[num][1]) 21 print("您購買了%s 價格為%d --您還有余額為\033[31;1m$%d\033[1m" % (shop[num][0],shop[num][1],money)) 22 elif money <= int(shop[num][1]): 23 print("您當前余額不足,剩余余額為:\033[31;1m$%d\033[1m"%(money)) shopping

?

轉載于:https://www.cnblogs.com/guiltyWay/p/9682323.html

總結

以上是生活随笔為你收集整理的python 的 购物小程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。