Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Is this a Phone Number?

Learning Objectives

In this lab, you will

  • Create a function according to the specifications
  • Use nested if/else statements

Instructions

Write a function, isPhoneNumber(digits), that checks to see if the input is a real phone number. This function should:

  • Return True if 'digits' is type int and is 10 digits long
  • Otherwise, returns False

You can use the assert statements to test that your function behaves as expected.

Hint: You can confirm 'digits' is an int with type(digits) == int

Hint: To check the length of the number, you can convert it to a string first, then check the length. Alternatively, you can use integer division.

# Define the function isPhoneNumber() below. The function should:
# - Check that the input value has type 'int' and is 10 digits long.
# - If this is true, return True
# - If this is false, return False
def isPhoneNumber(digits):
pass



# No print statement is needed for submission, but you can use a print statement to
# confirm the output of isPhoneNumber(digits) is as expected with various inputs .
if __name__ == "__main__":
assert isPhoneNumber("1234567890") == False
assert isPhoneNumber(1234567890) == True

Transcribed Image Text:1: Test isPhoneNumber(4243137890) returns True ^ 0/1 Test isPhoneNumber(4243137890) returns True Test feedback isPhoneNumber (4243137890) incorrectly returned None 2: Test isPhoneNumber(3109216754) returns True ^ 0/1 Test isPhoneNumber(3109216754) returns True Test feedback isPhoneNumber (3109216754) incorrectly returned None 3: Test isPhoneNumber(243137890) returns False ^ 0/1 Test isPhoneNumber(243137890) returns False Test feedback isPhoneNumber (243137890) incorrectly returned None 4: Test isPhoneNumber('sandwiches') returns False a 0/1 Test isPhoneNumber('sandwiches') returns False Test feedback isPhoneNumber ('sandwiches') incorrectly returned None
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education