This is python 3.4 problem. Thank you for your help. Part III: Identifying Credi
ID: 3814948 • Letter: T
Question
This is python 3.4 problem. Thank you for your help.
Part III: Identifying Credit Cards (3 points0 Write a function credit-card that takes an integer representing a credit card number and returns the brand of the credit card. The returned brand is given in all uppercase letters. If the card does not match any brand, the function returns None. The table below gives the details about the credit card number formats for several companies Brand of Digits Allowable Starting Digits ALPHA 16 4026, 417500, 4405 16 500-549 range of values) BETA GAMMA 16-19 (range of possible lengths) 62 OMEGA 14 300-305Explanation / Answer
def credit_card(n):
s= str(n)
m = int(s[0]);
if(m==4):
if(s.find('4026')==0 or s.find('417500')==0 or s.find('4405')==0):
return 'ALPHA'
elif(m==5):
tmp = int(s[0:3])
if(tmp>=500 and tmp<=549):
return 'BETA'
elif(m==6):
tmp = int(s[0:2])
if(tmp==62):
return 'GAMMA'
elif(m==3):
tmp = int(s[0:3])
if(tmp>=300 and tmp<=305):
return 'OMEGA'
d = credit_card(4175007282312321)
print(d)
d = credit_card(12)
print(d)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.