jimMoonrock

Untitled

Apr 26th, 2021
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.47 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def main_func():
  5.     num = random.randint(0000, 9999)
  6.     random.seed(num)
  7.     account_identifier = random.randint(0, 9)
  8.     check_sum = random.randint(0, 9)
  9.     user_card = int(f"400000{random.randint(1000000, 9999999)}{account_identifier}{random.randint(0, 9)}{check_sum}")
  10.     user_pin_card = int('{:04d}'.format(random.randrange(0000, 9999)))
  11.     user_balance = 0
  12.  
  13.     user_data = []
  14.  
  15.  
  16.     exit_from_main_cycle = False
  17.  
  18.     while not exit_from_main_cycle:
  19.         inp_user = input("1. Create an account\n2. Log into account\n0. Exit\n>")
  20.         print(" ")
  21.  
  22.         if inp_user == "1":
  23.             if not user_data:
  24.                 print(f"Your card has been created\nYour card number:\n{user_card}\nEnter your PIN:\n{user_pin_card}")
  25.                 user_data.append([int(user_card), user_pin_card])
  26.                 print(" ")
  27.  
  28.         elif inp_user == "2":
  29.  
  30.             if len(user_data) != 0:
  31.  
  32.                 loop_exit_condition = False
  33.  
  34.                 while not loop_exit_condition:
  35.                     check_card_number = int(input("Enter your card number:\n>"))
  36.                     pin_code_check = int(input("Enter your PIN:\n>"))
  37.  
  38.                     if check_card_number == user_data[0][0] and pin_code_check == user_data[0][1]:
  39.                         print(" ")
  40.                         print("You have successfully logged in!\n")
  41.  
  42.                         while not loop_exit_condition:
  43.  
  44.                             select_after_authorization = input("1. Balance\n2. Log out\n0. Exit\n>")
  45.                             print(" ")
  46.  
  47.                             if select_after_authorization == "1":
  48.                                 print(f"Balance: {user_balance}\n")
  49.                                 continue
  50.                             elif select_after_authorization == "2":
  51.                                 loop_exit_condition = True
  52.                                 print("You have successfully logged out!")
  53.                                 print(" ")
  54.                             elif select_after_authorization == "0":
  55.                                 loop_exit_condition = True
  56.                                 exit_from_main_cycle = True
  57.  
  58.                     else:
  59.                         print("Wrong card number or PIN!")
  60.                         continue
  61.             else:
  62.                 continue
  63.  
  64.         elif inp_user == "0":
  65.             print("Bye!")
  66.             break
  67.  
  68.  
  69.  
  70. if __name__=="__main__":
  71.     print(main_func())
Advertisement
Add Comment
Please, Sign In to add comment