Advertisement
jimMoonrock

Untitled

Apr 26th, 2021
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.70 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def main_func():
  5.     num = random.randint(0, 100)  # Создаем на кажый раз рандомное число
  6.     random.seed(num)
  7.     account_identifier = random.randint(0, 9)
  8.     check_sum = random.randint(0, 9)  # для будущего продолжения сумма
  9.     user_card = f"400000{random.randint(1000000, 9999999)}{account_identifier}{random.randint(0, 9)}{check_sum}" # Карта
  10.     user_pin_card = random.randint(1000,9999)  # Пин карты юзера
  11.     user_balance = 0
  12.  
  13.     user_data = []  # Для хранения данных пользователя
  14.     #print(user_card)
  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 == "Create an account":  # Выбор пользователя создать аккаунт
  23.             if len(user_data) == 0:  # чтобы не показывать данные каждую иттерацию
  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 == "Log into account":
  29.             #print(user_data)
  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.                                                                                                     #  в списке
  40.                         print("You have successfully logged in!\n")
  41.  
  42.                         while not loop_exit_condition:
  43.                             #print("1. Balance\n2. Log out\n0. Exit")
  44.                             select_after_authorization = input("1. Balance\n2. Log out\n0. Exit\n>")
  45.                             print(" ")
  46.  
  47.                             if select_after_authorization == "Balance":  # Если нужем баланс смотри и продолжаем работу
  48.                                 print(f"Balance: {user_balance}\n")
  49.                                 continue
  50.                             elif select_after_authorization == "Log out":  # Если нужем выйти в начальное меню
  51.                                 loop_exit_condition = True      # Выход из цикла
  52.                             elif select_after_authorization == "Exit":
  53.                                 loop_exit_condition = True  # Выход из циклов
  54.                                 exit_from_main_cycle = True  # Выход главного(внешнего цикла) из цикла
  55.  
  56.                     # Если данные не правильные возвращаемся в главное меню
  57.                     else:
  58.                         print("Wrong card number or PIN!")
  59.                         continue
  60.             else:
  61.                 continue
  62.  
  63.         elif inp_user == "Exit":
  64.             break
  65.  
  66. if __name__=="__main__":
  67.     print(main_func())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement