Question

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 = 21

d.

3 X 7 = 21

What do you typically use to model the relationships between the classes in an object-oriented program?

a.

UML diagrams

b.

Hierarchy charts

c.

Pseudocode

d.

Object models

In a three-tier architecture, the database tier stores the code that

a.

handles all monetary transactions

b.

controls the user interface

c.

accesses the file or database

d.

defines the business objects

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

2 numbers of Multiplier are num1=7 and num2=3

output would be 7 X 3 = 21

To Model relationships between classes in object-oriented program is
(a). UML diagrams

In a three-tier architecture, the database tier stores the code that
accesses the file or database

(c)

Add a comment
Know the answer?
Add Answer to:
Code Example 14-3 class Multiplier:     def __init__(self):         self.num1 = 0         self.num2 = 0     def...
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
  • class Leibniz:    def __init__(self):        self.total=0               def calculate_pi(self,n):       ...

    class Leibniz:    def __init__(self):        self.total=0               def calculate_pi(self,n):        try:            self.total, sign = 0, 1            for i in range(n):                term = 1 / (2 * i + 1)                self.total += term * sign                sign *= -1                self.total *= 4            return self.total        except Exception as e:   ...

  • Consider following flower class. class Flower: def __init__(self, Fname, numberofpetals, Fprice): self.Fname = Fname self.numberofpetals =...

    Consider following flower class. class Flower: def __init__(self, Fname, numberofpetals, Fprice): self.Fname = Fname self.numberofpetals = numberofpetals self.Fprice = Fprice def getName(self): return self.Fname def getPetalsCount(self): return self.numberofpetals def getPrice(self): return self.Fprice def setName(self, Fname): self.Fname = Fname def setPetalsCount(self, numberofpetals): self.numberofpetals = numberofpetals def setPrice(self, Fprice): self.Fprice = Fprice def main(): flower f, print("name = ", flower.getName()) flower.setName("jasmine") print("name = ", flower.getName()) main() Q. What is the statement to set an object flower with rose , 4 and price...

  • ill thumb up do your best python3 import random class CardDeck: class Card: def __init__(self, value):...

    ill thumb up do your best python3 import random class CardDeck: class Card: def __init__(self, value): self.value = value self.next = None def __repr__(self): return "{}".format(self.value) def __init__(self): self.top = None def shuffle(self): card_list = 4 * [x for x in range(2, 12)] + 12 * [10] random.shuffle(card_list) self.top = None for card in card_list: new_card = self.Card(card) new_card.next = self.top self.top = new_card def __repr__(self): curr = self.top out = "" card_list = [] while curr is not None:...

  • PYTHON -------------------------------------------------------- class LinkedList:    def __init__(self):        self.__head = None        self.__tail = None   

    PYTHON -------------------------------------------------------- class LinkedList:    def __init__(self):        self.__head = None        self.__tail = None        self.__size = 0    # Return the head element in the list    def getFirst(self):        if self.__size == 0:            return None        else:            return self.__head.element        # Return the last element in the list    def getLast(self):        if self.__size == 0:            return None        else:            return self.__tail.element    # Add an element to the beginning of the list    def addFirst(self, e):        newNode = Node(e) # Create a new node        newNode.next = self.__head # link...

  • class BinaryTree: def __init__(self, data, left=None, right=None): self.__data = data self.__left = left self.__right = right...

    class BinaryTree: def __init__(self, data, left=None, right=None): self.__data = data self.__left = left self.__right = right def insert_left(self, new_data): if self.__left == None: self.__left = BinaryTree(new_data) else: t = BinaryTree(new_data, left=self.__left) self.__left = t def insert_right(self, new_data): if self.__right == None: self.__right = BinaryTree(new_data) else: t = BinaryTree(new_data, right=self.__right) self.__right = t def get_left(self): return self.__left def get_right(self): return self.__right def set_data(self, data): self.__data = data def get_data(self): return self.__data def set_left(self, left): self.__left = left def set_right(self, right): self.__right...

  • 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...

  • I am trying to create a ATM style bank program that accept the customer id ,...

    I am trying to create a ATM style bank program that accept the customer id , in the welcoming panel ,but how do i make when the customer input their id# and click on the ok button then they have 3 or so tries to input the correct id# and if successful then send to the other panel where they choose which transaction to they want to make for example savings , checking account , make and deposit , and...

  • class Population: def __init__(self, m=0, n=0, k=0): # 1 self.m = m self.n = n self.k...

    class Population: def __init__(self, m=0, n=0, k=0): # 1 self.m = m self.n = n self.k = k self.encounter = 0 bac = [] bac = bac + [1] * self.m + [2] * self.n + [3] * self.k self.bac = bac def plasmids(self): # 2 set = (self.m, self.n, self.k) return set def __str__(self): # 3 return "type I: {}, type II: {}, type III: {} (after {} encounters)".format(self.m, self.n, self.k, self.encounter) def __repr__(self): # 4 return "Population({}, {},...

  • class Node(object): def __init__(self, data, next=None): self.data = data self.next = next class List(object):    def...

    class Node(object): def __init__(self, data, next=None): self.data = data self.next = next class List(object):    def __init__(self): self.head = None self.tail = None Implement the following functions for Linked List in Python and use the constructors above : Copy(lList) Builds and returns a copy of list ItemAt(List,i) Returns the data item at position i in list Pop(List,i=0) Remove item at position i in list. If i is not specified, it removes the first item in list Count(List,x) Returns the number...

  • COMPLETE THE _CONSTRUCT() AND CONSTRUCTTREE() FUNCTIONS class expressionTree:    class treeNode: def __init__(self, value, lchild, rchild):...

    COMPLETE THE _CONSTRUCT() AND CONSTRUCTTREE() FUNCTIONS class expressionTree:    class treeNode: def __init__(self, value, lchild, rchild): self.value, self.lchild, self.rchild = value, lchild, rchild def __init__(self): self.treeRoot = None    #utility functions for constructTree def mask(self, s): nestLevel = 0 masked = list(s) for i in range(len(s)): if s[i]==")": nestLevel -=1 elif s[i]=="(": nestLevel += 1 if nestLevel>0 and not (s[i]=="(" and nestLevel==1): masked[i]=" " return "".join(masked) def isNumber(self, expr): mys=s.strip() if len(mys)==0 or not isinstance(mys, str): print("type mismatch error: isNumber")...

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