Question: Python problems: 1/ __________ creates a list. (Choose all that apply) list1 = list() list1 = [] list1 = list([12, 4, 4]) list1 = [12,

Python problems:

1/ __________ creates a list. (Choose all that apply)

list1 = list()
list1 = []
list1 = list([12, 4, 4])
list1 = [12, 4, 4]

list1 = [1, "3", "red"]

2/ Analyze the following code:

class A: def __init__(self, s): self.s = s def print(self): print(self.s) a = A() a.print()

The program has an error because class A does not have a constructor.
The program has an error because s is not defined in print(s).
The program runs fine and prints nothing.

The program has an error because the constructor is invoked without an argument.

3/ Which classes are the exception classes in Python? (Choose all that apply)

ArithmeticError
IOException
RuntimeError

DivideByZeroError

4/ Is pow(a, b) the same as a ** b?

Yes

No

5/ The word True is ________. (Choose all that apply)

a Python keyword
a Boolean literal
same as value 1

same as value 0

6/ To generate a random integer between 0 and 5, use ________________.(Choose all that apply)

random.randint(0, 5)
random.randint(0, 6)
random.randrange(0, 5)
random.randrange(0, 6)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!