123 def verify(number): # do not change this line! # write your code here so that it verifies the card number # be sure to indent your code! return True # modify this line as needed 8 9 10 input = "5000-0000-0000" # change this as you test your function output = verify(input) # invoke the method using a test input print(output) # prints the output of the function 11 12 # do not remove this line! The rules must be checked in this order, and if any of the rules are violated, the function should return the violated rule number, e.g. if the input is "4238-0679-9123", then the function should return 2, indicating that rule #2 was violated because although rule #1 was satisfied (the first digit is a 4), rule #2 was not, since the fourth digit (which is 8) is not one greater than the fifth (which is 0). If all rules are satisfied, then the function should return True. Note that the card number is not actually a number, but is a string of characters. In Python, you can generally use a string the same way you would use a list, e.g. accessing individual characters using their 0-based index. Hint: You will need to do this for checking all the rules. However, when you access a character using its 0-based index, Python will treat it as a character/letter and not a number, even if it's a digit, and you need to be careful about how you use it in mathematical operations. For instance, if you had the characters '1' and '2' and try to add them, Python would concatenate them and use them to form a longer string; in this case, you would get "12". However, if you try to subtract, multiply, divide, etc. then Python will give you an error. To convert a character/letter to a number, use the "int" function, e.g. "x = int('1')" will convert the character/letter '1' to the number 1 so that you can use it in mathematical operations. Hint: you will need this for rules 2-4. 567
123 def verify(number): # do not change this line! # write your code here so that it verifies the card number # be sure to indent your code! return True # modify this line as needed 8 9 10 input = "5000-0000-0000" # change this as you test your function output = verify(input) # invoke the method using a test input print(output) # prints the output of the function 11 12 # do not remove this line! The rules must be checked in this order, and if any of the rules are violated, the function should return the violated rule number, e.g. if the input is "4238-0679-9123", then the function should return 2, indicating that rule #2 was violated because although rule #1 was satisfied (the first digit is a 4), rule #2 was not, since the fourth digit (which is 8) is not one greater than the fifth (which is 0). If all rules are satisfied, then the function should return True. Note that the card number is not actually a number, but is a string of characters. In Python, you can generally use a string the same way you would use a list, e.g. accessing individual characters using their 0-based index. Hint: You will need to do this for checking all the rules. However, when you access a character using its 0-based index, Python will treat it as a character/letter and not a number, even if it's a digit, and you need to be careful about how you use it in mathematical operations. For instance, if you had the characters '1' and '2' and try to add them, Python would concatenate them and use them to form a longer string; in this case, you would get "12". However, if you try to subtract, multiply, divide, etc. then Python will give you an error. To convert a character/letter to a number, use the "int" function, e.g. "x = int('1')" will convert the character/letter '1' to the number 1 so that you can use it in mathematical operations. Hint: you will need this for rules 2-4. 567
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Don't copy the code
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY