Python Program Problem - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Python Program Problem (3946 Views)
1 Reply
| Python Program Problem by eazyd(op): 11:58am On Mar 09, 2012 |
I wrote a program in python that 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. The program ask the user for the number of days worked, displays a table showing what the salary was for each day, and then show the total at the end of the period. I'm having problem with the last part-- (total at the end of the period.) This should calculate the total salary earned This is the program in python 2.7.2 print "Enter number of days worked:" def salary_on_day(n): return 2**(n-1) days = int(raw_input()) earnings = 0 for i in range(1, days): s=salary_on_day(i) print "day ", i, ": ", s, " pennies" earnings = s print "total: ",earnings |
| Re: Python Program Problem by eazyd(op): 1:17pm On Mar 09, 2012 |
well i went back to my book and found a skipped page- in there lies my answer accumulator Done Deal!! ![]() |
| Re: Python Program Problem by Mobinga: 7:00pm On Mar 09, 2012 |
Can Someone Please Help Me With This Python Program? • 2 • 3 • 4
I Just Spent Entire Night Coding!! And I Discovered That..... • Which Udemy Course Do You Need ? • Cyber Security In Nigeria!
