Question

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
    return volume

def main():
    l = 3
    w = 4
    h = 5
    v = get_volume(l, w, h)
    print(v)
    
if __name__ == "__main__":
    main()


Refer to Code Example 4-2: What value is passed to the height argument by the call to the get_volume() function?

a. 2

b. 3

c. 4

d. 5

Number 4)

Code Example 4-4
main program:
import arithmetic as a

def multiply(num1, num2):
    product = num1 * num2
    result = a.add(product, product)
    return result
    
def main():
    num1 = 4
    num2 = 3
    answer = multiply(num1, num2)
    print("The answer is", answer)

if __name__ == "__main__":
    main()

arithmetic module:
def add(x, y):
    z = x + y
    return z


Refer to Code Example 4-4: The add() function is called by

a. the main()

b. the arithmetic module  

c. function the multiply() function

d. the result statement

Number 5)

Code Example 4-1
def get_username(first, last):
    s = first + "." + last
    return s.lower()

def main():
    first_name = input("Enter your first name: ")
    last_name = input("Enter your last name: ")
    username = get_username(first_name, last_name)
    print("Your username is: " + username)
    
if __name__ == "__main__":
    main()


Refer to Code Example 4-1: What function is called first when the program runs?

a. get_username()

b.main()

c. input("Enter your first name: ")

d.  if __name__ == "__main__"

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

1) d. import temperature

2) a.from temperature import *  

3) d. 5

Explanation:

height is represented by h and value of h=5.

4) c. function the multiply() function

Explanation:

multiply() function calls add() function by passing two parameters .

5) b.main()

Explanation:

main() is the function called first when the program runs

Add a comment
Know the answer?
Add Answer to:
Number 1) Which of the following statements imports a module into the default namespace? a. from...
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
  • Fix this code so only the function prototype comes before main. #include <iostream> using namespace std;...

    Fix this code so only the function prototype comes before main. #include <iostream> using namespace std; bool isMultiple(int num1, int num2) { return num1 % num2 == 0; } int main() { char ch = 'Y'; int num1, num2; while(ch =='Y') // While ch is equal to Y { cout << "Enter two numbers(largest first): "; cin >> num1; // Getting 1st number cin >> num2; // Getting 2nd number if(isMultiple(num1, num2)) cout << num2 << " " << "IS...

  • (F) Specify the errors of the following code? 1) #include <iostrem> o stream 2) using namespace...

    (F) Specify the errors of the following code? 1) #include <iostrem> o stream 2) using namespace std; 3) int min() main 4) { 5) double num1 = 5, num2, sum; 6) num2 = 12; 7) sum = numl + num2, 8) cout << "The sum is ">> sum; 9) retrn 0; return 10)}

  • Python 3 Modify the sentence-generator program of Case Study so that it inputs its vocabulary from...

    Python 3 Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The filenames are nouns.txt, verbs. txt, articles.txt, and prepositions.txt. (HINT: Define a single new function, getWords. This function should expect a filename as an argument. The function should open an input file with this name, define a temporary list, read words from the file, and add them to the list. The function should then convert the list...

  • Write a python code that takes in an number 0-9 and prints out the word of...

    Write a python code that takes in an number 0-9 and prints out the word of the number. For example 1 would print out one. Below is the skeleton of the code that needs to be filled in. def num2string(num): """ Takes as input a number, num, and returns the corresponding name as a string. Examples: num2string(0) returns "zero", num2string(1)returns "one" Assumes that input is an integer ranging from 0 to 9 """ numString = "" ################################### ### FILL IN...

  • Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the...

    Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the program. The function should take number between 1 and 12 as a parameter and returns the corresponding month as a string. For example, if the parameter is 1, your function should return "January". If the parameter is 2, your function should return out "February", etc. def monthString(monthNum): """ Takes as input a number, monthNum, and returns the corresponding month name as a string. Example:...

  • Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born...

    Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born and print out all of the corresponding information using the overridden print method. Use the following code below as a starting point. ////////////////////////////////////////////////////// from datetime import datetime class Famous_Person(object): def __init__(self, last, first, month,day, year): self.last = last self.first = first self.month = month...

  • 10p Python For the following question, refer to the Python module on the right, as well...

    10p Python For the following question, refer to the Python module on the right, as well as the code below. 1) What is the output of the following code? #dodgeable.py #main dodgeable.py import dodgeable class Locatable: def NUM_CARS = 3 init (self,x,y): NUM TRUCKS = 2 self.mX = X WIDTH = 60 self.mY = y def setx (self,x): def main (): self.mX = x object_list = [] def sety (self, y): self.mY = y for i in range (NUM_CARS) :...

  • USING RECURSION ONLY...NO ITERATION Write a module called advancedmatch.py recursive function called ‘match(pattern, word)’ that can...

    USING RECURSION ONLY...NO ITERATION Write a module called advancedmatch.py recursive function called ‘match(pattern, word)’ that can be used to determine if a given pattern matches a given word. In this case, a pattern consists of letters and ‘?’ and ‘*’ wildcards. A ‘?’ wildcard matches any letter at the corresponding position in the word. A ‘*’ wildcard matches zero or more letters at the corresponding position in the word. Use aprogram called testadvanced.py that can be used to check your...

  • Could someone re-write this code so that it first prompts the user to choose an option...

    Could someone re-write this code so that it first prompts the user to choose an option from the calculator (and catches if they enter a string), then prompts user to enter the values, and then shows the answer. Also, could the method for the division be rewritten to catch if the denominator is zero. I have the bulk of the code. I am just having trouble rearranging things. ------ import java.util.*; abstract class CalculatorNumVals { int num1,num2; CalculatorNumVals(int value1,int value2)...

  • PYTHON: Conan is writing a module to contain different implementations of trees. After his first tree,...

    PYTHON: Conan is writing a module to contain different implementations of trees. After his first tree, the BinaryTreeclass, he wrote test code and is having problems understanding the error. Locate his problem and explain how you would fix it. class Node(object): def __init__(self, data=None): self.data = data def __str__(self): return "NODE: " + str(self.data)    class Tree(object): def __init__(self): self.root_node = None self.size = 0    def __len__(self): return self.size    def add(self, data): raise NotImplementedError("Add method not implemented.")    def inorder_traversal(self): raise NotImplementedError("inorder_traversal...

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