-
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 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”, 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__() : 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
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 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 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) 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 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 {
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 + "...