Question

For the Point class developed in class, which of the following lines of code causes the...

For the Point class developed in class, which of the following lines of
code causes the __repr__ method to execute?

Question 1 options:

a)

p = Point()

b)

p.setx(7)

c)

print(p)

d)

p.get()
Suppose: lst = []. Then, lst.extend([2]) is equivalent to executing:

Question 2 options:

a)

list.extend(lst)

b)

list.extend([2])

c)

list.extend(lst,[2])

d)

list.extend([2],lst)
Which list method does NOT have a return statement?
(hint:  [2,3]==[3,4] calls list.__eq__)

Question 3 options:

a)

__eq__

b)

__repr__

c)

append

d)

pop
The expression "apple"+"pear" is equivalent to which alternative expression?

Question 4 options:

a)

str.__add__("apple","pear")

b)

str(__add__,"apple","pear")

c)

__add__.str("apple","pear")

d)

__add__(str,"apple","pear")
What is the output of the following?

>>> lst = [2,3,4]
>>> lst2 = lst
>>> lst2.append( 5 )
>>> print( lst, lst2 )

Question 5 options:

a)

[2, 3, 4] [2, 3, 4]

b)

[2, 3, 4] [2, 3, 4, 5]

c)

[2, 3, 4, 5] [2, 3, 4]

d)

[2, 3, 4, 5] [2, 3, 4, 5]
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)  print(p)
2)  list.extend(lst,[2])
3)  append
4)  str.__add__("apple","pear")
5)  [2, 3, 4, 5] [2, 3, 4, 5]
Add a comment
Know the answer?
Add Answer to:
For the Point class developed in class, which of the following lines of code causes the...
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
  • Question 1 Select all the choices producing a string which contains multiple lines? Examples of each of the choices are presented below. #---------Option A--------------- s = ("Line 1","L...

    Question 1 Select all the choices producing a string which contains multiple lines? Examples of each of the choices are presented below. #---------Option A--------------- s = ("Line 1","Line 2") #---------Option B--------------- s = """Line 1 Line 2""" #---------Option C--------------- s = "Line 1\nLine 2" #---------Option D--------------- s = "Line 1" + "Line 2" #Option D Make your statements look the same as the examples. A. Using commas to separate lines B. Using triple-quotation marks C. Adding the newline character between...

  • from __future__ import annotations from typing import Any, Optional class _Node: """A node in a linked...

    from __future__ import annotations from typing import Any, Optional class _Node: """A node in a linked list. Note that this is considered a "private class", one which is only meant to be used in this module by the LinkedList class, but not by client code. === Attributes === item: The data stored in this node. next: The next node in the list, or None if there are no more nodes. """ item: Any next: Optional[_Node] def __init__(self, item: Any) ->...

  • . Write a Scheme program for each of the following. Which takes in two lists “lst1” and “lst2”, b...

    . Write a Scheme program for each of the following. Which takes in two lists “lst1” and “lst2”, both of which are individually sorted (in ascending order), and returns a list containing the elements of both lst1 and lst2 in sorted order. Print the final list. Input to the program are “lst1” and “lst2”. For instance, lst1 = (1 3 5 7) and lst2 = (2 4 6 8) output: (1 2 3 4 5 6 7 8)

  • Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() :...

    Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() : Since Pizza object don't have it's own set() datastructure, the toppings in the pizza object are manimupated from out of the object. (-1.0) 2. __eq__() : How about "self.toppings == other.toppings" rather than "self.toppings - other.toppin == set())". Code: ## Program 1 ## --------------------------------- class Pizza: def __init__(self, s='M', top=set()): self.setSize(s) self.toppings = top def setSize(self, s): self.size = s def getSize(self): return self.size...

  • Python 3 Here is my question. In clock.py, define class Clock which will perform some simple...

    Python 3 Here is my question. In clock.py, define class Clock which will perform some simple time operations. Write an initializer function for Clock that will take three arguments from the user representing hour (in 24-hour format), minutes, and seconds. Each of these parameters should have a reasonable default value. You should check that the provided values are within the legal bounds for what they represent and raise a ValueError if they are not. if error_condition: raise ValueError("Descriptive error message")...

  • C++ programing Which of the following statements (a-d) are true if the following lines of code...

    C++ programing Which of the following statements (a-d) are true if the following lines of code are executed? int G = 17; int &H = G; A. H is now an alternate name for G B. Adding 1 to H will change the value of G to 18 C. Subtracting 5 from G and printing H will display the value 12 D. The condition H == G will give a true result E. All of the statements (a-d) are true...

  • Which of the following is a virtual function declaration for Print(string str) from class Book? Select...

    Which of the following is a virtual function declaration for Print(string str) from class Book? Select one: a. virtual Print(string str); b. void Print(virtual string str); c. void virtual Print(string str); d. virtual void Print(string str);

  • Show the output of running the class Test in the following code lines: a) Nothing. b)...

    Show the output of running the class Test in the following code lines: a) Nothing. b) b is an instance of A followed by b is an instance of c c) b is an instance of C d) b is an instance of A interface A { void print (); } class C {} class B extends c implements A { public void print() { } } class Test { public static void main(String[] args) { B b = new...

  • ***IN PYTHON 2.7****Augment the following code with a new class named 'Coin'. Coin should inherit from...

    ***IN PYTHON 2.7****Augment the following code with a new class named 'Coin'. Coin should inherit from Die, with the following modifications; The constructor should not take any arguments; a coin always has two sides add a flip() method that uses the roll() method from the parent class. If roll returns 1; flip should return "HEADS". If roll returns a 2, flip should return "TAILS" Do not override the roll or rollMultiple methods from the parent class #!/usr/bin/python # your class...

  • abstract class Exp { abstract void print(); abstract int eval(); } class ConstExp extends Exp {...

    abstract class Exp { abstract void print(); abstract int eval(); } class ConstExp extends Exp { private int value; ConstExp(int v) { value = v; } void print() { System.out.print(value); } int eval() { return value; } } class BinaryExp extends Exp { private Exp arg1; private Exp arg2; private char op; BinaryExp(char op, Exp arg1, Exp arg2) { this.op = op; this.arg1 = arg1; this.arg2 = arg2; } void print() { System.out.print("("); arg1.print(); System.out.print(" " + op + "...

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