Unlock phone with code :
suppose you are coding a program. your goal is to check if the password entered by the user matches the phone password 1234. if it is match, the program will display "Phone Unlocked".
code :
entered_code=1234
#check if the entered code is correct or not
if entered_code==1234:
print("Phone Unlocked")
output :
Phone Unlocked
incorrect password :
entered_code=1235
#check if the entered code is correct or not
if entered_code==1234:
print("Phone Unlocked")
output :
ATM pin :
Recall the ATM scenario? we will create a program where we compare the PIN entered by the user with the actual PIN , which is 6789. if they match we will display withdraw Successful!
Code :
entered_pin=2345
if entered_pin==2345:
print("withdraw Successful!")
output :
withdraw Successful!
incorrect pin
entered_pin=2345
if entered_pin==1234:
print("withdraw Successful!")
output :
- You have to must try in your python compiler use idle avoid online compilers to Errors
0 Comments