0

How to i get the sum of the output numbers equal to 180(im not english speaking person so ig u understood me)

The code i used,correct it if needed x = 0 c = 0 while x < 180: print(x) x+=2 c+=1 if x == 180: print(x) print("Amount of the numbers is "+str(c))

18th Jan 2023, 4:28 PM
Line Crimnal
Line Crimnal - avatar
35 Réponses
+ 9
Line Crimnal , not quite clear what kind of issue do you have. > can you give some more information?
18th Jan 2023, 4:50 PM
Lothar
Lothar - avatar
+ 3
You can see how your code works in this way: x = 0 c = 0 while x < 180: print(f"x in the while loop: {x}") x+=2 c+=1 if x == 180: print(f"\nx in if statement: {x}") print(f"\nx after while loop: {x}") print("\nAmount of the numbers is c: "+str(c)) https://code.sololearn.com/cpX42hHqLXa9/?ref=app
18th Jan 2023, 5:30 PM
JaScript
JaScript - avatar
+ 2
If you want <c> value becomes 180 then increment <x> by one, not two Inside loop body ... x += 1 # not x += 2
18th Jan 2023, 4:54 PM
Ipang
+ 2
why do you keep adding 2 twice? it's only two days and the task is complete.... last day is second day.There is no 3rd day. going back to my 89 91 answer day1 89 task total = 89 day2 89+2=91 task total=89+91=180 no day3 because 180 tasks are done in day2. the 2nd day is 2 task more than the first day. That is the condition. If it is only 2 days, the second day is EVERYDAY... I have to make it 2 days because of the 2 more task condition. But there it is. The second day is two more than the first and 180 task is done! what is expected? did you not define it by the amount of task done in the first day? then the amount of task in the second day should be first day+2. not first day +2+2, as you keep trying to compute it. see my previous example. I followed your first calculation exactly...😅 Also, the expected does not enter the computation at all. the first day determines the calculation. Perhaps this way The expected is 87. day1 87+2=89 day2 89+2=91 180 complete. and yes, I can add...
22nd Jan 2023, 7:00 AM
Bob_Li
Bob_Li - avatar
+ 1
How many task he was expected to do daily? need to know that so we can add 2 to that number everyday until it sums up to 180 ... This feels more maths than coding though ...
18th Jan 2023, 5:17 PM
Ipang
+ 1
x=0 while x<=180: print("Amount of the numbers is "+str(x)) x+=1
20th Jan 2023, 4:04 PM
viswajeet
viswajeet - avatar
+ 1
Bob_Li You are correct. Line Crimnal has not mentioned clearly what the problem is. If somebody wants a resolution for the problem, he/she must mention example as you did. Let consider a problem like this- A boy will do 1 job first day. Then , he will do 1+2 job next day. Like wise, he will do 2 more job than previous day. So- 1st day-1 job 2nd day-1+2 =3 job 3rd day - 3+2=5 job ....... It is the problem to be dealt with permutation. We can create a loop using while, for and it will give the result. As you mentioned, if we consider I job per day, then also we can create a loop and it will give result. *Search for permutation in internet if you are unaware of permutation
21st Jan 2023, 2:51 AM
viswajeet
viswajeet - avatar
+ 1
Bob_Li everyday he did 2 tasks more than he expected EVERYDAY.. Can you understand that? Ok, I explain for you, everyday mean that in first day ➕ 2, second day➕ 2, last day or not whatever +2, In second day 91(+2) cause 91 ➕ 2 tasks more than he expected. Can you add 91+2? XD and first day 89 plus 2 more than he expected. first day(89+2) +(91+2) second day Where added 2 twice?? What's not Clear?
22nd Jan 2023, 5:31 AM
Smith Welder
Smith Welder - avatar
+ 1
And your calculation is wrong, cause 90 and 90(+2) 92 in the second day will 182, not 180, it's false for condition, understand? :)
22nd Jan 2023, 6:14 AM
Smith Welder
Smith Welder - avatar
+ 1
this is the end of the discussion, my stomach already hurts from laughter😂
22nd Jan 2023, 8:46 AM
Smith Welder
Smith Welder - avatar
+ 1
yes, this is enough. why 9 days if you can do it in 2. moving on...
22nd Jan 2023, 8:57 AM
Bob_Li
Bob_Li - avatar
0
So i get the numbers like 2,4,6,8,10,12 etc. And im trying to get their summary that equals 180
18th Jan 2023, 4:52 PM
Line Crimnal
Line Crimnal - avatar
0
Ig its not even possible
18th Jan 2023, 4:53 PM
Line Crimnal
Line Crimnal - avatar
0
I had a task,i tried to code it,so the task is: "The student had to do 180 tasks,everyday he did 2 tasks more than he expected,how many days will it take to make 180 tasks?"
18th Jan 2023, 5:03 PM
Line Crimnal
Line Crimnal - avatar
0
Im new to programming so ig its out of my hands
18th Jan 2023, 5:04 PM
Line Crimnal
Line Crimnal - avatar
0
Let <x> be 2 # so dilligent, 2 tasks completed already from the beginning Let <c> be 0 Let <days> be 0 While <c> less than 180 Begin Add 2 to <x> Add <x> to <c> Increment <days> End If all goes well, here <c> value becomes 180, and we also have the number of days (<days>) counted for ... Give it a try? (Edited)
18th Jan 2023, 5:52 PM
Ipang
19th Jan 2023, 8:50 AM
Smith Welder
Smith Welder - avatar
0
Be free use the language you are comfortable with.This is a big community.
20th Jan 2023, 12:07 PM
Ochola Mark Joshua
Ochola Mark Joshua - avatar
0
60 days if it is two more than expected 1 per day... https://code.sololearn.com/cUSfXB1PHnk3/?ref=app
20th Jan 2023, 1:17 PM
Bob_Li
Bob_Li - avatar
0
The fun fact is that on the maths we got 10 days,but he completed them 1 day earlier so the answer is 9
20th Jan 2023, 1:18 PM
Line Crimnal
Line Crimnal - avatar