How do you write a loop in python with conditional statements in python?

0 votes
Can you show an example with both if else and control statements like break or continue ?
Jul 8 in Python by Waseem
• 4,480 points
33 views

1 answer to this question.

0 votes

Lets say we have a problem statement to check if the number is greater, smaller or less than 5.

x = int (input('enter a number'))

while x > 0 :

    if x == 5:

       print("equall")

    elif x > 5:

       print("greater")

    else: 

      print(" smaller")
answered Jul 8 by Mohammad
• 3,060 points

Related Questions In Python

0 votes
0 answers
+2 votes
1 answer

How do you make a block comment in python?

''' This is a multiline comment. I ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 56,540 points
56 views
0 votes
1 answer

How do you add a background thread to flask in Python?

The example below creates a background thread ...READ MORE

answered Nov 19, 2018 in Python by Nymeria
• 3,520 points
6,895 views
0 votes
1 answer

How do I get a random number with a float range in python?

Use random.uniform(a, b): Returns a random floating point ...READ MORE

answered May 27 in Python by Kiran
23 views
+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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 237 views
+4 votes
6 answers
0 votes
1 answer
0 votes
1 answer

How do you select a python interpreter in Pycharm?

Follow the following steps: Open the settings Open Project ...READ MORE

answered Aug 2 in Python by Mohammad
• 3,060 points
47 views