Which of the following is equivalent to x != y?
![]()
Practice Logical Operators Questions – Which of the following is equivalent to x != y?
![]()
Practice Logical Operators Questions – Which of the following is equivalent to x != y?
![]()
Practice Expressions Questions – The word True is ________.
![]()
Practice Classes and Objects – Analyze the following code:
class A:
def __init__(self):
self.x = 1
self.__y = 1
def getY(self):
return self.__y
a = A()
a.x = 45
print(a.x)
![]()
Practice Functions Programming – What will be displayed by the following code?
def f1(x = 1, y = 2):
x = x + y
y += 1
print(x, y)
f1(y = 2, x = 1)
![]()
Practice Classes and Objects – Analyze the following code:
class A:
def __init__(self, s = “Welcome”):
self.s = s
def print(self):
print(self.s)
a = A()
a.print()
![]()
Practice Lists programming – What will be displayed by the following program?
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
v = values[0][0]
for row in range(0, len(values)):
for column in range(0, len(values[row])):
if v < values[row][column]:
v = values[row][column]
print(v)
![]()
Practice Functions Programming – What will be displayed by the following code?
def f1(x = 1, y = 2):
x = x + y
y += 1
print(x, y)
f1(y = 2, x = 1)
![]()
Practice Recursion Questions – Analyze the following recursive function.
def factorial(n):
return n * factorial(n – 1)
![]()
Practice Python Libraries Questions – The time.time() returns ________________ .
![]()
Practice Sets Programming – Suppose s = {1, 2}, 2 * s is _________.
![]()
Practice Sets Programming – Suppose s1 = {1, 2, 4, 3} and s2 = {1, 5, 4, 13}, s1 + s2 is ____________?
![]()
Practice Relational Operators – Analyze the following code fragments that assign a boolean value to the variable even.
Code 1:
if number % 2 == 0:
even = True
else:
even = False
Code 2:
even = True if number % 2 == 0 else False
Code 3:
even = number % 2 == 0
![]()
Practice Exception Handling – What is displayed when the following program is run?
try:
list = 10 * [0]
x = list[10]
print(“Done”)
except IndexError:
print(“Index out of bound”)
else:
print(“Nothing is wrong”)
finally:
print(“Finally we are here”)
![]()
Practice Lists programming – Assume m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], what are len(m)?
![]()
Practice Classes and Objects – Analyze the following code:
class A:
def __init__(self, s):
self.s = s
def print(self):
print(s)
a = A(“Welcome”)
a.print()