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, 2019 in Python by Waseem
• 4,540 points
939 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, 2019 by Mohammad
• 3,230 points

Related Questions In Python

0 votes
0 answers

How do you use an else clause in a while loop in python?

Can you give an example? READ MORE

Aug 5, 2019 in Python by Waseem
• 4,540 points
729 views
+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
• 58,020 points
969 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,560 points
36,851 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, 2019 in Python by Kiran
995 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,442 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,078 views
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, 2019 in Python by Mohammad
• 3,230 points
2,575 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