Trying to find totals to declining numbers... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Trying to find totals to declining numbers...

I am trying to build a python code that adds a set number ‘example A = 1.5’ to a group for each day of the week. But each day the group gets slightly smaller by user pulling out random numbers, based on user input, so each day varies. At the end of the week I would like to know the total of the group left over and the amount of example A that was given in total.... Any amount of help would be appreciated 🙂

11th Jun 2019, 2:46 PM
Brandon Nichols
Brandon Nichols - avatar
3 Answers
+ 1
n=int(input('Enter the constant number')) Ans=n*7 for i in range(7): print('Enter the number to be reduced on day',i+1) x=int(input()) Ans-=x print(Ans)
11th Jun 2019, 3:07 PM
Pulkit Kamboj
Pulkit Kamboj - avatar
+ 1
The first line i am taking input of the constant that is added each day, so to get it for seven days, i have multiplied it by 7. Now we take the seven inputs and reduce from the number.
11th Jun 2019, 3:30 PM
Pulkit Kamboj
Pulkit Kamboj - avatar
0
Hi, thanks ill try that out. could you elaborate on what is going on in the code so i can understand please? thank you!
11th Jun 2019, 3:24 PM
Brandon Nichols
Brandon Nichols - avatar