How to divide one number to another multiple times untill it will be about 0

0 votes

How to divide one number to another multiple times, until it will be about 0?

For example 128 / 2, then 64 / 2, then 32/2, and so on.
Please help me, how can I write the cycle?

Nov 10, 2020 in Python by anonymous
• 10,480 points
2,776 views

1 answer to this question.

0 votes

You can do something like this: 

while num != 0:
    num//=2
          print(num)

In the num, you could put any num, e.g, num=128

r you could ask the User for an input

To see the output use a print(num) statement

answered Nov 10, 2020 by Gitika
• 65,770 points

Related Questions In Python

0 votes
1 answer

How do I append one string to another in Python?

If you only have one reference to ...READ MORE

answered Oct 22, 2018 in Python by SDeb
• 13,300 points
739 views
0 votes
1 answer
0 votes
1 answer

How to write content of one file to another file in Python?

The following code snippet might solve your ...READ MORE

answered Aug 26, 2019 in Python by Neel
• 3,020 points
789 views
0 votes
1 answer

How to add multiple columns to pandas dataframe in one assignment?

Hello @kartik, You could use assign with a dict of ...READ MORE

answered Jun 15, 2020 in Python by Niroj
• 82,840 points
15,932 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,070 views
0 votes
4 answers

Is it possible to call one python script from another Python Script?

Try using os.system: os.system("script2.py 1") execfile is different because it is ...READ MORE

answered Dec 16, 2020 in Python by Gitika
• 65,770 points
70,359 views
0 votes
1 answer

How to write a code In Python where input will be 1 then the output will be 2?

You can go through this:  def num(number): ...READ MORE

answered Oct 7, 2020 in Python by Gitika
• 65,770 points
1,275 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP