1 / 30

What is the result of:

s = 'python'
print(not s.startswith('j') and s.endswith('n') or len(s) == 4)

2 / 30

Examine the following Python code:

a = True
b = False

if a and b:
print("Both a and b are true")
elif a or b:
print("At least one of a or b is true")
else:
print("Neither a nor b is true")

What will be the output of this code?

3 / 30

What is the expected output of the following code?

data1 = '1', '2'

data2 = ('3', '4')

print(data1 + data2)

4 / 30

What is the output of:

x = 5
print(-(-x), +x, --x)

5 / 30

What is the output of:

print(bin(0b1111 & 0b1010), bin(0b1111 | 0b1010))

6 / 30

What is the output of:

x = [1, 2, 3]
y = x[:]
y.append(4)
print(x)

7 / 30

What will this code print:

x = 5
y = -x
z = +y
print(x + y + z)

8 / 30

Which of the following best describes the role of an interpreter?

An interpreter reads the source code instruction by instruction, executing each line immediately. Unlike a compiler, it doesn't create a separate executable file.

9 / 30

What will be the output of the following code:

x = 1
print(x)
x = 2
print(x)

10 / 30

What will be printed:

x = True
y = False
print(~x + ~y)

11 / 30

What is the result of:

x = 0b1111
print(bin(x >> 2), bin(x << 1))

12 / 30

What is the result of:

x = 300
y = 300
z = 300
print(x is y, y is z)

13 / 30

What is the output of:

x = 10
y = 3
print(x % y * 2 ** 2)

14 / 30

Code:

list = [False, True, "2", 3, 4, 5]

#insert code here

print(b)

Insert the correct code so that the program produces

True

15 / 30

What is the primary difference between a compiler and an interpreter?

A compiler processes the whole program upfront, creating an executable. An interpreter goes through the code line by line, executing as it goes.

16 / 30

What is the expected output of the following code?

list1 = [1, 3]

list2 = list1

list1[0] = 4

print(list2)

17 / 30

What is the expected output of the following code?

data = (1, 2, 4, 8)

data = data[-2:-1]

data = data[-2:-1]

data = data[-1]

print(data)

18 / 30

What is the result of:

s = 'Python'
print(list(enumerate(s)), dict(enumerate(s)))

19 / 30

Which of the following is a keyword in Python that is used to define a function?

The def keyword is how you define a function in Python. It signals to the interpreter that you are about to create a new, reusable block of code.

20 / 30

What is the result of:

print(bool(0.0) + bool('') + bool(None) + bool([0]))

21 / 30

What is the output of the following code?

my_list = [3, 1, -1]

my_list[-1] = my_list[-2]

print(my_list)

22 / 30

What will be the output of the following code snippet?

a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

print(a[::2])

23 / 30

What is the result of:

s = 'Python3.9'
print(s.isalnum(), s.isalpha(), s.isdecimal())

24 / 30

Which of the following is the correct way to define a string in Python?

In Python, you can define strings using either single quotes ('...') or double quotes ("..."). Both are perfectly valid and equivalent.

25 / 30

What will this code print:

x = 5e-324
y = 5e-325
print(x > 0, y > 0, x == y)

26 / 30

What is the result of:

print('Hello' * 0, 'World' * True)

27 / 30

What will this code print:

print(3 * 2 ** 2 / 4 + 1)

28 / 30

What will this code print:

x = 255
print(f'{x:b} {x:o} {x:x} {x:d}')

29 / 30

What file extension is created when Python source code is compiled?

30 / 30

What will this code print:

x = 100
print(isinstance(x, int) and x > 0 and x % 2 == 0)

Your score is