Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,207,421 members, 7,998,964 topics. Date: Sunday, 10 November 2024 at 01:07 PM

I need assistance with this Python Problem - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / I need assistance with this Python Problem (375 Views)

Who Can Help Out With This Python Problem? / Can Someone Help Me With A Solution To This Python Problem / Python Masters, Kindly Help Me Rectify This Python Problem. (2) (3) (4)

(1) (Reply) (Go Down)

I need assistance with this Python Problem by Tarvel(m): 12:37pm On Jan 07, 2021
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(m): 1:48pm On Jan 07, 2021
Anybody?
Re: I need assistance with this Python Problem by Tarvel(m): 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(m): 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(m): 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(m): 2:45pm 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

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(m): 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 Like

(1) (Reply)

Gambling Site With Reliable Games / Android Developer Looking For A Ios Developer As A Friend / Javascript Projects Suggestion

(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. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.