Untitled
unknown
python
4 years ago
3.9 kB
4
Indexable
# BIN = primele 6 cifre (st la dreapta) # Bank Identification Number # MII = Major industry identifier # prima cifra # 1 and 2 are issued by airlines # 3 is issued by travel and entertainment # 4 and 5 are issued by banking and financial institutions # 6 is issued by merchandising and banking # 7 is issued by petroleum companies # 8 is issued by telecommunications companies # 9 is issued by national assignment # The first six digits are the Issuer Identification Number (IIN). # These can be used to look up where the card originated from. # Visa: 4***** # American Express (AMEX): 34**** or 37**** # Mastercard: 51**** to 55**** # Account Identifier (9 cifre) # 7 - 15 # Most companies use just 9 digits for the account numbers, but it’s possible to use up to 12 # checksum # ultima cifra # The very last digit of a credit card is the check digit or checksum. # It is used to validate the credit card number using the Luhn algorithm # END OF BRIEF ########### # exercitiu: # in our banking system, the IIN must be 400000 # In our banking system, the customer account number can be any, # but it should be unique. # And the whole card number should be 16-digit length # You should allow customers to create a new account in our banking system. # Once the program starts, you should print the menu: # 1. Create an account # 2. Log into account # 0. Exit # If the customer chooses ‘Create an account’, you should generate a new card number # which satisfies all the conditions described above. # Then you should generate a PIN code that belongs to the generated card number. # A PIN code is a sequence of any 4 digits. PIN should be generated in a range from 0000 to 9999. #If the customer chooses ‘Log into account’, # you should ask them to enter their card information. # Your program should store all generated data until it is terminated # so that a user is able to log into any of the created accounts # by a card number and its pin. # You can use an array to store the information. # After all information is entered correctly, # you should allow the user to check the account balance; # right after creating the account, the balance should be 0. # It should also be possible to log out of the account and exit the program. from random import randint print("1. Create an account") print("2. Log into account") print("0. Exit") user_input = int(input()) while user_input != 0: if user_input == 1: class Card(): def __init__(self, card_increment = 1): self.card_increment = card_increment def random_with_N_digits(self, n): range_start = 10**(n-1) range_end = (10**n)-1 return randint(range_start, range_end) def generate_new_card_nr(self): customer_account_number = self.random_with_N_digits(9) IIN = 400000 checksum = self.random_with_N_digits(1) card = str(IIN) + str(customer_account_number) + str(checksum) print("") print("Your card has been created") print("Your card number:") print(card) return card def generate_pin(self): pin = self.random_with_N_digits(4) print("Your card PIN:") print(pin) return pin client1 = Card() client1.generate_new_card_nr() client1.generate_pin() print("") print("1. Create an account") print("2. Log into account") print("0. Exit") user_input = int(input()) elif user_input == 2: print("") print("Enter your card number:") login_card_number = int(input()) print("Enter your PIN:") login_pin = int(input()) else: print("bad input") break
Editor is loading...