如何使用此Python显示游戏的成本
我如何使用Python显示游戏的成本,使用如下代码:如何使用此Python显示游戏的成本,python,Python,我如何使用Python显示游戏的成本,使用如下代码: if game_list[game]>= 10: print ("The Price for this Game is: $"), game_prices[game]*1.1 如果这是python3.x,则必须按照以下步骤执行: if game_list[game]>= 10: print ("The Price for this Game is: $", game_prices[ga
if game_list[game]>= 10:
print ("The Price for this Game is: $"), game_prices[game]*1.1
如果这是python3.x,则必须按照以下步骤执行:
if game_list[game]>= 10:
print ("The Price for this Game is: $", game_prices[game]*1.1)
对于python2.7,它将是:
if game_list[game]>= 10:
print "The Price for this Game is: $"+game_prices[game]*1.1
您最好授权价格设置逻辑:
def game_price(game):
price = game_list[game]
if price >= 10:
markup = 0.1
else:
markup = 0.2
return price * (1. + markup)
print("The game's price is ${:0.2f}".format(game_price(game)))