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
• 3,480 points
23 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
• 1,500 points

Related Questions In Python

+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,160 points
43 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,500 points
4,657 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
13 views
0 votes
0 answers

How do you parse a string in python?

After splitting the string, how does parsing ...READ MORE

Jul 8 in Python by Waseem
• 3,480 points
11 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 128 views
0 votes
0 answers
0 votes
1 answer

how do I check the length of an array in a python program?

lets say we have a list mylist = ...READ MORE

answered Mar 12 in Python by Mohammad
• 1,500 points
27 views
0 votes
1 answer

what does a conditional operator in python do?

Conditional operators in python is same as ...READ MORE

answered May 2 in Python by Mohammad
• 1,500 points
30 views