Python-13 march 25(While loop)
Python-13 march 25(While loop)
1.while loop
2.for loop
While loop
Syntax Python
WHILE condition
print (“------”)
Count=count+1
initialValue = 1
while intialValue<=10
Example: 06 print(initialValue)
Algorithm:
1. System must have a secret number.
2. System will give chance to user for 3 times for
guessing the secret number.
3.System must count guess from 1
4. System will allow user to give input when it will
be in between (3)guess limit.
5. If user’s guess & secret number is same, system
will show you a massage “you win” or after 3
chances it will show you “you lose… ”
Guessing Game
Pseudo Code:
DECLARE guessNum= INTEGER
SecretNumber =5 secret_num= 3
guessLimit=3 guess_limit =3
guessCount=1 guess_count = 1
OUTPUT “Enter your guessNumber:”
while guess_count <=guess_limit:
guess_num=int(input("guess:
WHILE guessCount<=guessLimit "))
INPUT guessNum guess_count=guess_count+1
guessCount= guessCount+1 if guess_num==secret_num:
print("you win")
IF guessNum==SecretNumber else:
print("you lose... :( )")
THEN
OUTPUT “you win”
ELSE
OUTPUT “you lose ”
ENDIF
ENDWHILE
THANK YOU