₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,092 members, 8,420,280 topics. Date: Thursday, 04 June 2026 at 03:34 PM

Toggle theme

I need assistance with this Python Problem - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingI need assistance with this Python Problem (452 Views)

1 Reply (Go Down)

I need assistance with this Python Problem by Tarvel(op):
Good afternoon, I need assistance

For example

a = int(input())

while True:
Print ( a // 2)

The problem is how do I make variable a equal to the next answer, and then the next answer equal to the next?

Let's say a = 10
It'll print 5
How do I make it print (5 // 2)
And then print (2 // 2)...

I'm not sure if I explained it properly, but I need assistance. Thanks in advance
Re: I need assistance with this Python Problem by Tarvel(op): 1:48pm On Jan 07, 2021
Anybody?
Re: I need assistance with this Python Problem by Tarvel(op): 1:57pm On Jan 07, 2021
Tarvel:
Good afternoon, I need assistance

For example

a = int(input())

while True:
Print ( a // 2)

The problem is how do I make variable a equal to the next answer, and then the next answer equal to the next?

Let's say a = 10
It'll print 5
How do I make variable a equal 5 so that it'll automatically print (5 // 2)
And then print (2 // 2)...

I'm not sure if I explained it properly, but I need assistance. Thanks in advance
I've modified my question
Re: I need assistance with this Python Problem by Nobody: 2:10pm On Jan 07, 2021
You assign the answer to the same variable

a = int(input())

while a > 0 : #You don't want an infinite loop
a = a/2
print(a)

This is what I understood from the question
Re: I need assistance with this Python Problem by Tarvel(op): 2:34pm On Jan 07, 2021
This is what I'm trying to figure out

Re: I need assistance with this Python Problem by Tarvel(op): 2:34pm On Jan 07, 2021
DrLevi:
You assign the answer to the same variable

a = int(input())

while a > 0 : #You don't want an infinite loop
a = a/2
print(a)

This is what I understood from the question
Please check the picture above, thanks
Re: I need assistance with this Python Problem by Tarvel(op):
DrLevi:
You assign the answer to the same variable

a = int(input())

while a > 0 : #You don't want an infinite loop
a = a/2
print(a)

This is what I understood from the question
I want an infinity loop, I want it to continue giving me the output of a but with the consecutive answers till I get 1 as my answer
Re: I need assistance with this Python Problem by Tarvel(op): 3:10pm On Jan 07, 2021
I've gotten it now, thanks smiley sad

Re: I need assistance with this Python Problem by Deicide: 5:48pm On Jan 07, 2021
Remove that While b==True
1 Reply

Who Can Help Out With This Python Problem?Help With This Python Programming Assignment PleaseCan Someone Help Me With A Solution To This Python Problem234

Tech Instructor NeededUnderstanding Quickbook PreferencesBest Travel API Provider - B2C Travel Portal Development