Question

Code Example 10-1 1. phone_number input(Enter phone number: ).strip() 2. if len(phone_number)10: 3. phone_number+phone_number[:3]) + phone_number[3:6] + - + phone_number[6:] 4. print(Phone number:, phone_number) 5. else 6. print(Phone number:, Phone number must be 10 digits) Referto Code Example 10-1. Iftheuserenterstwo extra spacesattheend of a phonenumber what will happen? a. The length of thenumber wil begreater than 10 so theelse clause willexecute. b. The strip) method on line 1 will strip away the extra whitespace. C. The else clause will be executed. d. Whitespace at the end of the input is always ignored.Code Example 4-2 Code Example 4-2 def get_volume(width, height, length 2) volumewidth height length return volume def main) W-4 h=5 v - get_volume(I, w, h) printv) if-name -main-: main) Referto Code Example 4-2: If youaddthefollowing code to theend of the main() method, what does it print to the console? printiget_volume(10, 2)) 40 Nothing, it causes an error 60 20 a. b. C. d.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

10-1 :

if using strip at the end it will remove all the space from left side and from right. So phone number won't be greater than 10 digit , it will be same as entring phone number without space.

so correct option is B

4-2---------------------

If adding print(get_volume(10,2)) it will call the function with default value for third parameter(length) that is 2.

So result will be 10*2*2 = 40 option A

Add a comment
Know the answer?
Add Answer to:
Code Example 10-1 1. phone_number input("Enter phone number: ").strip() 2. if len(phone_number)10: 3. phone_number""+phone_number[:3]")" + phone_number[3:6]...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Number 1) Which of the following statements imports a module into the default namespace? a. from...

    Number 1) Which of the following statements imports a module into the default namespace? a. from temperature import * b. import temperature as t c. import temperature as temp d. import temperature Number 2) Which of the following statements imports a module into the global namespace? a.from temperature import *   b. import temperature as temp c. import temperature as global d. import temperature Number 3) Code Example 4-2 def get_volume(width, height, length=2):     volume = width * height * length...

  • Code Example 9-2 number = float(input("Enter a number: ")) result1 = number * .15 result2 =...

    Code Example 9-2 number = float(input("Enter a number: ")) result1 = number * .15 result2 = result1 / 3 result3 = result1 + result2 print(result3) Refer to Code Example 9-2. When this code is executed, which of the variables might contain approximate results instead of accurate results? a. result1 b. result2 and result3 c. result1, result2, and result3 d. result1 and result2

  • Can you please enter this python program code into an IPO Chart? import random def menu():...

    Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...

  • The skeleton code (starter file) for the problem is pasted below: def phoneNumber(letters): result = ""...

    The skeleton code (starter file) for the problem is pasted below: def phoneNumber(letters): result = "" # ADD YOUR CODE HERE return result def loadEvents(filename): events = {} # ADD YOUR CODE HERE return events def timeline(events): # ADD YOUR CODE HERE return # DO NOT modify or remove the code below! We will use it for testing. if __name__ == "__main__": # Problem 1: Decoding Telephone Numbers ph = input("Enter the text to translate: ") print("The corresponding phone number...

  • In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as...

    In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as keys and an array for key containing a list of values (words from file of respective size) associated with those keys I am reading from a file of strings, where I am only interested with words of length 4, 5, and 6 to compute my program reading the text file line by line: At first, I have an empty dictionary then to that I...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • build a phone number from digits entered by your user. Your program will loop until 10...

    build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • What is the result of the following: print(input("Enter a number")* 2) if you entered 9. oooo...

    What is the result of the following: print(input("Enter a number")* 2) if you entered 9. oooo 13 Error What is the result of t = (1, 3.5): t.append(7) O (1,3,5,7) O (1,3,5) O (7) Error To check if there is a WIN in a tic-tac-toe game, the program has to check * O 6 lines of 3 boxes O 8 lines of 3 boxes O 9 boxes O The Center What is the result of print( int("3" + "5") +...

  • 12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers...

    12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers are:') 3 for i in range (2,25): 4 isone (i) 5 def isone (number): isOne = True i = 2 while i < number and is one: if number % i == 0: 10 isOne = False 11 i += 1 Lou if isOne == True: 13 print("\t', i) 14 main() 12 13. What is the output of this program? Your answer: for i...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT