In: Computer Science
When you use an automated teller machine (ATM) with your bank
card, you need to use a personal identification number (PIN) to
access your account. If a user fails more than three times when
entering the PIN, the machine will block the card. Assume that the
user's PIN is "1234" and write a program in python that asks the
user for the PIN no more than three times, and does the
following:
1. If the user enters the right number, print a message saying ,
"Your PIN is correct", and end the program
2. If the user enters a wrong number, print a message saying, "Your
PIN is incorrect" and, if you have asked fro the PIN less than
three times, ask for it again
3. If the user enters a wrong number three times, print a message
saying "Your bank card is blocked" and end the program.
in this in python pls
Python code:
#initializing PIN as 1234
PIN=1234
#initializing flag as 0
flag=0
#looping for 3 times
for i in range(3):
#asking for pin
user_pin=int(input("Enter your pin: "))
#checking if it is correct
if(user_pin==PIN):
#printing correct
print("Your PIN is correct")
#setting flag as 1
flag=1
#exiting loop
break
else:
#printing incorrect
print("Your PIN is incorrect")
#checking if flag is 0
if(flag==0):
#printing card is blocked
print("Your bank card is blocked")
Screenshot:
Input and Output: