Which statement do I use!?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Which statement do I use!??

Here is my homework question: Design a program 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 prog. should ask the user for the number of days worked. Display a table showing what the salary was for each day, and then show the total pay at the end..." I am so confused on how to get my code to work! How do I use a while statement run, if the limits are whatever the user inputs?!?!

22nd Feb 2017, 2:15 AM
auri
auri - avatar
8 Answers
+ 5
maybe you can add this line: days=int(input("enter your salary days:") that line will change user input into integer then you can set limit of iteration by something like this: i=1 while i<=days:
22nd Feb 2017, 2:44 AM
Agus Mei
Agus Mei - avatar
+ 5
Raj code is bettet
22nd Feb 2017, 2:59 AM
Agus Mei
Agus Mei - avatar
+ 2
If I use For, how can I get the table I need to print the days (ie 1,2,3) in order? Sorry I am a super newb at this. Also how the heckkk do I write the user input code? Int(input? Float(input? Just input?! I'm so lost any help is very much appreciated
22nd Feb 2017, 2:40 AM
auri
auri - avatar
+ 2
Thank you guys so much! Raj you are gods gift to python noobs haha :) Auri
22nd Feb 2017, 3:55 AM
auri
auri - avatar
+ 1
hey here is code for you https://code.sololearn.com/c8b1832eN8VQ/?ref=app you can modify according to your need.
22nd Feb 2017, 2:48 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
+ 1
check it now, now its more according to your need https://code.sololearn.com/c8b1832eN8VQ/?ref=app
22nd Feb 2017, 2:57 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
0
It is GM series, total pay till n will be (2^n-1) and table will keep multiply by 2 till we have n.
22nd Feb 2017, 2:21 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
0
Auri...saying god gifted to a learner like me is a wrong choice of word. but still I appreciate your feelings :p but yeah you shouldn't post your homeworks here, if you are struck from somewhere ..ask for that. or if needed ask for logic but at last try to code by yourself . now you dont just copy my code...code by yourself and ask me if have any doubt. cheers..have a good day :)
22nd Feb 2017, 4:39 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar