Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,568 members, 7,809,070 topics. Date: Thursday, 25 April 2024 at 10:20 PM

Python Program Problem - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Program Problem (3779 Views)

Can Someone Please Help Me With This Python Program? (2) (3) (4)

(1) (Reply)

Python Program Problem by eazyd(m): 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(m): 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!! grin
Re: Python Program Problem by Mobinga: 7:00pm On Mar 09, 2012

(1) (Reply)

[RESOLVED] How do I package my database with my application? / Urgent Help Needed On How To Save Fingerprint To Sql Using U Are U 4500 And Java / Get Complete Android Development Videos +java Videos Begin Your Journey

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.