Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,217,556 members, 8,034,628 topics. Date: Sunday, 22 December 2024 at 07:14 AM

I need assistance with this Python Problem - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / I need assistance with this Python Problem (384 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)

I Wanna Learn A Skill Like Programming / Complete Ethical Hacking Bootcamp 2021: Zero To Mastery / Best Tools To Create Visualizations

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