0

I am working on a project where I have to issue card to each and every account that has been created, below are the methods that I have to create within the class to have the card issued and with an expiry date as mentioned in the below criteria , we are not allowed to import anything beyond random or datetime method, we can use loops for same

  • cardNumber – The card number, which should be a string containing a 16-digit number ( should be importing and use the random module for this).

  • cardExperience - a tuple, where the first element is an integer corresponding to the month and the second element is 2-digit year. Eg: 03/23 represents March 2023. (should be importing and use the datetime module for this).

  • issueNewCard(self) Creates a new card number, with the expiry date being 3 years to the month from now (e.g., if today is 31/1/21, then the expiry date would be (01/24)).

     def IssueNewCard(self):
     CardNumber = list(range(1000000000000000,9999999999999999))
     IssuedCardNumber = random.sample(CardNumber)
     today=datetime.date.today("%y","%m")
     print(IssuedCardNumber)
     print(today)
    
Ash
  • 9
  • 3
  • Hello! Welcome to SO. Instead of posting the project question, it could best if you post your current work at the code and point to the specific problem you face on it. – coldy Dec 12 '21 at 21:46
  • Hi Coldy, i have added the sample code as well – Ash Dec 13 '21 at 00:19

1 Answers1

0
def issueNewCard(self):
    """
    The issueNewCard method issues each user with the unique 16-digit card, with the expiry date of 3years from the date of now.
    We are importing random and datetime module to fetch the random 16-digit number and have the current date.

    The CardNumber is string of 16-digit which are extracted by help of Random Module
    
    A tuple is created for card expiry to have the first element as month and the second element is 2-digit year

    """
    self.cardNum = str(random.randint(10**15,(10**16)-1))
    today=datetime.date.today()
    self.cardExp = today.month,int(str(today.year+3)[2:])
    #print("The card number is {self.CardNumber} \n with a expiry date of {self.Expiry}".format(self=self))
Ash
  • 9
  • 3