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,420 points
55 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,870 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,250 points
138 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
146 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,560 points
6,620 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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,847 views
0 votes
0 answers
+4 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,810 points
1,421 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,870 points
13,434 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 6, 2020 in Python by Gitika
• 65,870 points
69 views