Question

I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import...

I need help with my python class. thanks!

Question 12

  1. 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 multiply() function

    b.

    the main() function

    c.

    the arithmetic module

    d.

    the result statement

4 points

Question 13

  1. Code Example 4-3
    main program:

    import arithmetic as a

    def main():
        num1 = 5
        num2 = 6
        result = a.add(num1, num2)
        print("The sum is", result)
       
    if __name__ == "__main__":
        main()


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

    Refer to Code Example 4-3: What values are in x and y after the code runs?

    a.

    9, 8

    b.

    5, 6

    c.

    20, 12

    d.

    4, 2

4 points

Question 14

  1. Python comments

    a.

    are ignored by the compiler

    b.

    can be used to document what a program or portion of code does

    c.

    can be used so certain lines of code are not executed during testing

    d.

    all of the above

4 points

Question 15

  1. 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: When this program runs, what does it print to the console?

    a.

    24

    b.

    v

    c.

    60

    d.

    40

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Question 12:
the multiply() function

Question 13:
5, 6

Question 14:
all of the above

Question 15:
60
Add a comment
Know the answer?
Add Answer to:
I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import...
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...

  • How do I make my code print out the text in the ServiceNotifier class? Python Code:...

    How do I make my code print out the text in the ServiceNotifier class? Python Code: class ServiceNotifier: #Subject responsible for notifying registered observer objects    Observer = [Email, SMS, Phone]       def attach(self):    #add new observer        Observer.append(insertnewobserverhere)    def dettach(self):    #remove an observer        Observer.pop(insertnewobserverhere)    def servicenotifier(self):        for observers in Observer:            print("Due to the forecast for tomorrow, all university and campus operations will be closed.")       ...

  • AND logic gate simulation in Python: Please fix the code below so that it efficiently performs...

    AND logic gate simulation in Python: Please fix the code below so that it efficiently performs the operation of the AND logic gate in Python. (Leave comments in the edited code about what you changed) #if both values are 1, return true, other wise return false print ("Logic Gate Simulation: AND gate") def AND(x, y):     if x == True and y == True:         return True        else:         return False    def main():     x = bool(input("Please...

  • Hello! I'm looking for help with this assignment. Complete a program in pseudocode and Python that...

    Hello! I'm looking for help with this assignment. Complete a program in pseudocode and Python that performs the following tasks. Open the file called M4Lab1ii.py linked below these instructions in your M4 Content module in IDLE. Save as M4Lab1ii.py. Replace ii with your initials. [example for someone with the initials cc: M4Lab1cc.py] Complete Steps 1-7 as requested within the code’s comments. Run your program and test all four calculations, then exit the program. Save your program as M4Lab1ii.py using your...

  • Write a program that does the following in Python Code: Write a new Class called Famous_Day_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...

  • 1 Show the output from the following Python code fragment: for i in [ 12, 4,...

    1 Show the output from the following Python code fragment: for i in [ 12, 4, -2]:      print (2 * i) 2 Write a Python program findAverage to find the average of the numbers in a range defined by two inputs num1 and num2, where the values of num1 and num2 are entered by the user. For example, a call to findAverage(2,10) would find the average of the numbers 2,3,4,5,6,7,8,9 (note the final "10" is NOT included!). The output...

  • Code Example 14-3 class Multiplier:     def __init__(self):         self.num1 = 0         self.num2 = 0     def...

    Code Example 14-3 class Multiplier:     def __init__(self):         self.num1 = 0         self.num2 = 0     def getProduct(self):         return self.num1 * self.num2 def main():     m = Multiplier()     m.num1 = 7     m.num2 = 3     print(m.num1, "X", m.num2, "=", m.getProduct()) if __name__ == "__main__":     main() Refer to Code Example 14-3: When this code is executed, what does it print to the console? a. 7 X 3 = 0 b. 3 X 7 = 0 c. 7 X 3...

  • ### Question in python code, write the code on the following program: def minmaxgrades(grades, names): """...

    ### Question in python code, write the code on the following program: def minmaxgrades(grades, names): """ Computes the minimum and maximujm grades from grades and creates a list of two student names: first name is the student with minimum grade and second name is the student with the maximum grade. grades: list of non-negative integers names: list of strings Returns: list of two strings """ def main(): """ Test cases for minmaxgrades() function """ input1 = [80, 75, 90, 85,...

  • I need help with the adding the following to my python code (also provided below) M5A6Part2...

    I need help with the adding the following to my python code (also provided below) M5A6Part2 ⦁   When a user successfully votes, add the user’s voterID to the _voterIDsVoted list ⦁   When a user successfully votes, increment the value of the variable that counts the votes for the candidate the user voted for. This would be either _candidateAVotes or _candidateBVotes Hint: run your original test code again. If you reused a valid voter ID in your tests it should cause...

  • This is a python question. from urllib import request import json """ Complete this program that...

    This is a python question. from urllib import request import json """ Complete this program that calculates conversions between US dollars and other currencies. In your main function, start a loop. In the loop, ask the user what currency code they would like to convert to And, how many dollars they want to convert. If you scroll down, you can see an example response with the available 3-letter currency codes. Call the get_exchange_rates() function. This function returns a dictionary with...

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