我正在編寫一個程序,計算一個人在一段時間內的收入金額,如果他的工資是第一天的一分錢,第二天便是兩便士,並繼續每天兩次。 我把一切都做,但我必須進入美元,我不知道如何做到這一點只漂浮給了我0.0當我需要.00python便士一天數字功能
感謝
# Ryan Beardall Lab 8-1 10/31/13
#program calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day and continues to double each day.
accumulatedPay = []
payPerDay = []
days = []
#User enters days worked to find out ho much money user will have
def numberDays():
global daysWorked
daysWorked = (input("Enter the days worked "))
return daysWorked
def salaryOnDay(daysWorked):
return float((2**(daysWorked-1))/100)
def calculations():
earnings = 0
for i in range (1, daysWorked + 1):
salary = salaryOnDay(i)
currRow = [0, 0, 0]
currRow[0] = i
currRow[1] = salary
earnings += salary
currRow[2] = earnings
days.append(currRow)
#program prints matrix
def main():
numberDays()
calculations()
for el in days:
print el
main()
它沒有工作我得到了一個錯誤 –
你使用的是什麼版本的Python?你得到了什麼錯誤?你是如何解決這個錯誤的(或者你是如何試圖解決的)? –