While loop with "If" in Python
#while loop with if
test=0
size=50
while(test<size):
test+=1
print(test)
if(test>49):
test-=1
#print(test)
#while with else
n=25
while n<0:
n-=1
print(n)
if n==2:
break
else:
print("loop done")
vowels="aeiouAEIOU"
#INFINITE LooP
while True:
v=input("enter vowel:")
#condition in middle
if v in vowels:
break
print("not vowel")
print("thank you")
#dice program
from random import randint
print("Give lower limit of dice")
a = int(input())
print("Give upper limit of dice")
b = int(input())
print("type q to Quit or any other key/enter to continue")
while True:
print(">>> "+str(randint(a,b))) #randint is generating random number between a and b
if input() == 'q': #if 'q' is entered then come out of loop
break
Comments
Post a Comment