From 1972c9b14b1b7fd81b2c4acf9a271f2743539153 Mon Sep 17 00:00:00 2001 From: Amlan Mohanty <72063042+amlanmohanty1@users.noreply.github.com> Date: Sat, 3 Oct 2020 00:30:00 +0530 Subject: [PATCH 1/4] added a program --- .../P80_checking_validation_of_credit_card.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Programs/P80_checking_validation_of_credit_card.py diff --git a/Programs/P80_checking_validation_of_credit_card.py b/Programs/P80_checking_validation_of_credit_card.py new file mode 100644 index 0000000..ce43cc4 --- /dev/null +++ b/Programs/P80_checking_validation_of_credit_card.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +"""Checking_validation_of_Credit_card.ipynb + +Automatically generated by Colaboratory. + +Original file is located at + https://colab.research.google.com/drive/1i7AszLLJi-Mrw_iWR10w2F7icdopWFMf +""" + +def validity_check(num): # this function adds every digit of the card number to a list and, + validlist=[] + for i in num: + validlist.append(int(i)) + for i in range(0,len(num),2): # applying Luhn Algorithm to check whether resulting sum is divisible by ten + validlist[i] = validlist[i] * 2 + if validlist[i] >= 10: + validlist[i] = (validlist[i]//10 + validlist[i]%10) + + if sum(validlist)% 10 == 0: + print("This is a VALID CARD!") + + else: + print('INVALID CARD NUMBER') + +def card_number(): # accepts card number as a string + + n ='' + while True: + try: + n = input('Enter your 16 digit credit card number : ') + + if not (len(n) == 16) or not type(int(n) == int) : + raise Exception + + except Exception: + print('That is not a valid credit card number. \nMake sure you are entering digits not characters and all the 16 digits.') + continue + + else: + break + + + return n + +def goagain(): + return input('Do you want to check again? (Yes/No) : ').lower()[0] == 'y' + +def main(): + + while True: + + num = card_number() + validity_check(num) + + + if not goagain(): + break + +if __name__ == '__main__': + main() \ No newline at end of file From 634c5478ce89d57a920f43b18f14fbb1d2ac5d77 Mon Sep 17 00:00:00 2001 From: Amlan Mohanty <72063042+amlanmohanty1@users.noreply.github.com> Date: Sat, 3 Oct 2020 00:31:51 +0530 Subject: [PATCH 2/4] updated README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c79a6c5..30c43dc 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Pune, Maharashtra, India.
2. [Hangman](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P37_HangmanGame.py) 3. [Rock Paper Scissor](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P49_RockPaperScissors.py) 4. [Tic Tac Toe](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P75_TicTacToe.py) +5. [Credit card validation checker](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P80_checking_validation_of_credit_card.py) ## OOP From da763fc8c04a492947655f5ba0d5fa3550627af1 Mon Sep 17 00:00:00 2001 From: Amlan Mohanty <72063042+amlanmohanty1@users.noreply.github.com> Date: Sat, 3 Oct 2020 00:33:58 +0530 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30c43dc..96ed95d 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Pune, Maharashtra, India.
2. [Hangman](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P37_HangmanGame.py) 3. [Rock Paper Scissor](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P49_RockPaperScissors.py) 4. [Tic Tac Toe](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P75_TicTacToe.py) -5. [Credit card validation checker](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P80_checking_validation_of_credit_card.py) +5. [Credit card validation checker](P80_checking_validation_of_credit_card.py) ## OOP From 91fa0296316cff13f2bb4f4470491624189709fd Mon Sep 17 00:00:00 2001 From: Amlan Mohanty <72063042+amlanmohanty1@users.noreply.github.com> Date: Sat, 3 Oct 2020 00:35:12 +0530 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96ed95d..959ae9e 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Pune, Maharashtra, India.
2. [Hangman](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P37_HangmanGame.py) 3. [Rock Paper Scissor](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P49_RockPaperScissors.py) 4. [Tic Tac Toe](https://github.com/OmkarPathak/Python-Programs/blob/master/Programs/P75_TicTacToe.py) -5. [Credit card validation checker](P80_checking_validation_of_credit_card.py) +5. Credit card validation checker P80_checking_validation_of_credit_card.py ## OOP