Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

debug my code accodeing to the instruction and troubleshoot plz - Create a function according to the specifications - Use nested if/else statements Instructions Write

debug my code accodeing to the instruction and troubleshoot plz image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
- Create a function according to the specifications - Use nested if/else statements Instructions Write a function, is_phone_num (digits), that expects an integer number and returns a boolean value to indicate if the input is a "real" phone number. This function should return a Boolean value: - Return True if digits is type int, is 10 digits long and the first digit is not a 0 - Otherwise, return False You can use the assert statements to test that your function behaves as expected. assert is phone num ("1234567890") =* False * input is not an integer assert is phone_num (1234567890)= True I a valid 10 -digit number Hints - You can confirm that 'digits' is an int with type(digits) == int-note that we use just int not int (), because we want the type itself, not to call the corversion function. - 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. 1 \# Define the function is_phone_num() below. 2 def is_phone_num(digits): 3 if type(digits) = int and digits>=1000000000 and digits 1000000000 : 4 return "True" 5 else: 6 retuen "Faise" 7 print(is_phone_num( "1234567890")) 8 print(is_phone_num( 1234567890)) Function works incorrectly. Test feedback If there are no other errors, then check it's name, the parameters and return values. 2.Unit test Test is.phone_num(3109216754) returns True Function works incorrectly. Test feedback If there are no other errors, then check it's name, the parameters and return values. Test is_phone_num(sandwiches) returns False Function works incorrectly. Test feedback If there are no other errors, then check it's name, the parameters and return values. 5.Unit test Test is phone num(12345678910) returns False Function works incorrectly. Test feedback If there are no other errors, then check it's name, the parameters and return values. 6 Unit test Test is..phone. num(123) returns False TestfeedbackIftherearenoothererrors,thencheckitsname,theparametersandreturnvalues.Functionworksincorrectly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions