Site icon Exam4Training

Python Institute PCEP-30-02 PCEP – Certified Entry-Level Python Programmer Online Training

Question #1

Insert the correct snippet so that the program produces the expected output.

Expected output:

Code:

  • A . b = 0 not in list
  • B . b = list[0]
  • C . b = 0 in list
  • D . b = False

Reveal Solution Hide Solution

Correct Answer: C
Question #2

Assuming that the tuple is a correctly created tuple, the fact that tuples are immutable means that the following instruction:

  • A . is illegal
  • B . may be illegal if the tuple contains strings
  • C . can be executed if and only if the tuple contains at least two elements
  • D . is fully correct

Reveal Solution Hide Solution

Correct Answer: A
Question #3

What is the expected output of the following code?

  • A . 2
  • B . 4
  • C . 5
  • D . 3

Reveal Solution Hide Solution

Correct Answer: B
Question #4

What is the expected output of the following code?

  • A . [1, 3]
  • B . [1, 4]
  • C . [4, 3]
  • D . [1, 3, 4]

Reveal Solution Hide Solution

Correct Answer: C
Question #5

What is the expected output of the following code?

  • A . [‘Peter’, 404, 3.03, ‘Wellert’, 33.3]
  • B . None of the above.
  • C . [404, 3.03]
  • D . [‘Peter’, ‘Wellert’]

Reveal Solution Hide Solution

Correct Answer: C
Question #6

Take a look at the snippet, and choose the true statements: (Choose two.)

  • A . nums is longer than vals
  • B . nums and vals are of the same length
  • C . vals is longer than nums
  • D . nums and vals refer to the same list

Reveal Solution Hide Solution

Correct Answer: BD
Question #7

What is the output of the following snippet?

  • A . 12
  • B . (2, 1)
  • C . (1, 2)
  • D . 21

Reveal Solution Hide Solution

Correct Answer: D
Question #8

What is the expected output of the following code?

print(list(‘hello’))

  • A . hello
  • B . [h, e, l, l, o]
  • C . [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
  • D . [‘h’ ‘e’ ‘l’ ‘l’ ‘o’]
  • E . None of the above.

Reveal Solution Hide Solution

Correct Answer: C
Question #9

What will be the output of the following code snippet?

  • A . [1, 3, 5, 7, 9]
  • B . [8, 9]
  • C . [1, 2, 3]
  • D . [1, 2]

Reveal Solution Hide Solution

Correct Answer: A
Question #10

What will be the output of the following code snippet?

  • A . 3
  • B . 2
  • C . 4
  • D . 1

Reveal Solution Hide Solution

Correct Answer: C

Question #11

What is the output of the following snippet?

  • A . two
  • B . one
  • C . (‘one’, ‘two’, ‘three’)
  • D . three

Reveal Solution Hide Solution

Correct Answer: A
Question #12

What is the expected output of the following code?

  • A . [3, 1, 25, 5, 20, 5, 4]
  • B . [1, 3, 4, 5, 20, 5, 25]
  • C . [3, 5, 20, 5, 25, 1, 3]
  • D . [1, 3, 3, 4, 5, 5, 20, 25]
  • E . [3, 4, 5, 20, 5, 25, 1, 3]

Reveal Solution Hide Solution

Correct Answer: C
Question #13

Which of the following sentences is true?

  • A . str1 and str2 are different (but equal) strings.
  • B . str1 and str2 are different names of the same strings.
  • C . str1 is longer than str2
  • D . str2 is longer than str1

Reveal Solution Hide Solution

Correct Answer: B
Question #14

The fact that tuples belong to sequence types means:

  • A . they can be modi fi ed using the del instruction
  • B . they can be extended using the .append() method
  • C . they are actually lists
  • D . they can be indexed and sliced like lists

Reveal Solution Hide Solution

Correct Answer: D
Question #15

What is the output of the following code?

  • A . [1, 1, 1]
  • B . [3, -1, 1]
  • C . [3, 1, 1]

Reveal Solution Hide Solution

Correct Answer: C
Question #16

What is the expected output of the following code?

  • A . The code is erroneous.
  • B . 6
  • C . 5
  • D . 4

Reveal Solution Hide Solution

Correct Answer: D
Question #17

What is the expected output of the following code?

  • A . (‘Peter’: 30, ‘Paul’: 31)
  • B . (‘Peter’, ‘Paul’)
  • C . [‘Peter’: 30, ‘Paul’: 31]
  • D . [‘Peter’, ‘Paul’]

Reveal Solution Hide Solution

Correct Answer: D
Question #18

What is the output of the following snippet?

  • A . 2
  • B . 4
  • C . The snippet is erroneous (invalid syntax)

Reveal Solution Hide Solution

Correct Answer: B
Question #19

What is the expected output of the following code?

  • A . (4)
  • B . 4
  • C . (4,)
  • D . 44

Reveal Solution Hide Solution

Correct Answer: B
Question #20

What is the output of the following snippet?

  • A . [1, 1, 2, 2]
  • B . [1, 1, 1, 2]
  • C . [1, 2, 1, 2]
  • D . [1, 2, 2, 2]

Reveal Solution Hide Solution

Correct Answer: B

Question #21

What is the expected output of the following code?

  • A . 4
  • B . 6
  • C . 5
  • D . 3

Reveal Solution Hide Solution

Correct Answer: B
Question #22

A data structure described as LIFO is actually a:

  • A . stack
  • B . tree
  • C . list
  • D . heap

Reveal Solution Hide Solution

Correct Answer: A
Question #23

How would you remove all the items from the d dictionary?

Expected output:

Code:

  • A . d.del()
  • B . d.remove()
  • C . del d
  • D . d.clear()

Reveal Solution Hide Solution

Correct Answer: D
Question #24

What is the expected output of the following code?

  • A . three
  • B . (‘one’, ‘two’, ‘three’)
  • C . two
  • D . one

Reveal Solution Hide Solution

Correct Answer: D
Question #25

What is the expected output of the following code?

  • A . False
  • B . 1
  • C . 0
  • D . True

Reveal Solution Hide Solution

Correct Answer: A
Question #26

Which one of the lines should you put in the snippet below to match the expected output?

Expected output:

Code:

  • A . reverse(list)
  • B . list.reversed()
  • C . list.reverse()
  • D . reversed(list)

Reveal Solution Hide Solution

Correct Answer: C
Question #27

What is the expected output of the following code?

  • A . [‘1’, ‘2’, ‘3’, ‘4’]
  • B . (1, 2, 3, 4)
  • C . (‘1’, ‘2’, ‘3’, ‘4’)
  • D . The code is erroneous.

Reveal Solution Hide Solution

Correct Answer: C
Question #28

What is the expected output of the following code?

  • A . (2)
  • B . (2,)
  • C . 2
  • D . The code is erroneous.

Reveal Solution Hide Solution

Correct Answer: C
Question #29

What is the output of the following snippet?

  • A . -2
  • B . 3
  • C . -1
  • D . 1

Reveal Solution Hide Solution

Correct Answer: D
Question #30

An alternative name for a data structure called a stack is:

  • A . LIFO
  • B . FIFO
  • C . FOLO

Reveal Solution Hide Solution

Correct Answer: A

Question #31

What is the expected output of the following code?

  • A . [7, 3, 23, 42]
  • B . [7, 20, 23, 42]
  • C . [10, 20, 42]
  • D . [10, 20, 23, 42]

Reveal Solution Hide Solution

Correct Answer: B
Question #32

Take a look at the snippet and choose one of the following statements which is true:

  • A . vals is longer than nums
  • B . nums and vals are of the same length
  • C . nums is longer than vals

Reveal Solution Hide Solution

Correct Answer: B
Question #33

What is the expected output of the following code?

  • A . (1, 2)
  • B . The code is erroneous.
  • C . {‘a’:1, ‘b’:2}
  • D . [1,2]

Reveal Solution Hide Solution

Correct Answer: B
Question #34

How many elements does the L list contain?

  • A . one
  • B . two
  • C . three
  • D . zero

Reveal Solution Hide Solution

Correct Answer: D
Question #35

What is the output of the following snippet?

  • A . 1
  • B . 0
  • C . 6

Reveal Solution Hide Solution

Correct Answer: B
Question #36

What is the expected output of the following code?

  • A . (‘Peter’, ‘Peter’,)
  • B . PeterPeter
  • C . The code is erroneous.
  • D . (‘Peter’)
  • E . ()

Reveal Solution Hide Solution

Correct Answer: E
Question #37

What is the expected output of the following code?

  • A . The program will cause an error.
  • B . (1, 4, 9)
  • C . (‘A’, ‘D’, ‘Z’)
  • D . (5.0, 7.5, 9.9)

Reveal Solution Hide Solution

Correct Answer: C
Question #38

What is the expected output of the following code?

  • A . The code is erroneous.
  • B . 1
  • C . 0
  • D . None

Reveal Solution Hide Solution

Correct Answer: A
Question #39

What is the expected output of the following code?

  • A . 22
  • B . 12
  • C . 0
  • D . 11

Reveal Solution Hide Solution

Correct Answer: B
Question #40

What is the expected output of the following code?

  • A . (2, 1, 1)
  • B . (1, 1, 1)
  • C . (2, 2, 2)
  • D . The code is erroneous.

Reveal Solution Hide Solution

Correct Answer: D

Question #41

Which one of the lines should you put in the snippet below to match the expected output?

Expected output:

Code:

  • A . sorted(list)
  • B . sort(list)
  • C . list.sort()
  • D . list.sorted()

Reveal Solution Hide Solution

Correct Answer: C
Question #42

Which of the following sentences are true about the code? (Choose two.)

  • A . nums and vals are different lists
  • B . vals is longer than nums
  • C . nums and vals are different names of the same list
  • D . nums and vals have the same length

Reveal Solution Hide Solution

Correct Answer: CD
Question #43

The second assignment:

  • A . extends the list
  • B . doesn’t change the list’s length
  • C . shortens the list

Reveal Solution Hide Solution

Correct Answer: B
Question #44

What is the expected output of the following code?

  • A . efg
  • B . abc
  • C . def
  • D . The code is erroneous.
  • E . abcde
  • F . None of the above.

Reveal Solution Hide Solution

Correct Answer: A
Question #45

Which function does in-place reversal of objects in a list?

  • A . list.sort([func])
  • B . list.pop(obj=list[-1])
  • C . list.remove(obj)
  • D . list.reverse()

Reveal Solution Hide Solution

Correct Answer: D
Question #46

What is the output of the following snippet?

  • A . [1, 2, 3]
  • B . [3, 3, 3]
  • C . [3, 2, 1]
  • D . [1, 1, 1]

Reveal Solution Hide Solution

Correct Answer: C
Question #47

What snippet would you insert in the line indicated below to print .

The highest number is 10 and the lowest number is 1. to the monitor?

A ) None of the above.

B )

C )

D )

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: D
Question #48

What is the output of the following snippet?

  • A . [‘Mary’, ‘had’, ‘a’, ‘little’, ‘lamb’]
  • B . [‘Mary’, ‘had’, ‘a’, ‘lamb’]
  • C . [‘Mary’, ‘had’, ‘a’, ‘ramb’]
  • D . No output, the snippet is erroneous

Reveal Solution Hide Solution

Correct Answer: D
Question #49

What is the expected output of the following code?

  • A . Paul
  • B . Mary
  • C . The code is erroneous.
  • D . None of the above.
  • E . Peter

Reveal Solution Hide Solution

Correct Answer: E
Question #50

What is the expected output of the following code?

  • A . 1
  • B . 4
  • C . 3
  • D . 2

Reveal Solution Hide Solution

Correct Answer: C

Question #51

What is the expected output of the following code?

  • A . 0
  • B . 1
  • C . The code is erroneous.
  • D . 2

Reveal Solution Hide Solution

Correct Answer: A
Question #52

What is the expected output of the following code?

  • A . The code is erroneous.
  • B . [‘Peter’, ‘Jane’, ‘Mary’]
  • C . [‘Peter’, ‘Jane’]
  • D . [‘Paul’, ‘Mary’, ‘Jane’]

Reveal Solution Hide Solution

Correct Answer: A
Question #53

What is the expected output of the following code?

  • A . 24
  • B . 13
  • C . 31
  • D . 42

Reveal Solution Hide Solution

Correct Answer: A
Question #54

What is the expected output of the following code?

  • A . 4
  • B . 10
  • C . Nothing gets printed.
  • D . The code is erroneous.

Reveal Solution Hide Solution

Correct Answer: B
Question #55

After execution of the following snippet, the sum of all vals elements will be equal to:

  • A . 4
  • B . 5
  • C . 2
  • D . 3

Reveal Solution Hide Solution

Correct Answer: A
Question #56

What is the expected output of the following code?

  • A . 4
  • B . 2
  • C . 10
  • D . 0
  • E . 1
  • F . 3

Reveal Solution Hide Solution

Correct Answer: A
Question #57

What is the output of the following snippet?

  • A . [0, 1, 9, 16]
  • B . [0, 1, 4, 16]
  • C . [0, 1, 4, 9]
  • D . [1, 4, 9, 16]

Reveal Solution Hide Solution

Correct Answer: C
Question #58

What is the expected output of the following code?

  • A . [4, 3, 2, 1]
  • B . [4, 3, 2]
  • C . [4, 3]
  • D . The code is erroneous.

Reveal Solution Hide Solution

Correct Answer: B
Question #59

Take a look at the snippet and choose one of the following statements which is true:

  • A . nums and vals are of the same length
  • B . nums is longer than vals
  • C . vals is longer than nums

Reveal Solution Hide Solution

Correct Answer: C
Question #60

What is the expected output of the following code?

  • A . 01
  • B . 10
  • C . The code is erroneous.
  • D . 00

Reveal Solution Hide Solution

Correct Answer: C

Question #61

What code would you insert instead of the comment to obtain the expected output?

Expected output:

Code:

  • A . print(k[0])
  • B . print(k)
  • C . print(k[‘0’])
  • D . print(k["0"])

Reveal Solution Hide Solution

Correct Answer: A
Question #62

What is the expected output of the following code?

  • A . 15913
  • B . 1234
  • C . 13 14 15 16
  • D . 481216

Reveal Solution Hide Solution

Correct Answer: D
Question #63

What is the expected output of the following code?

  • A . The code is erroneous.
  • B . 2
  • C . 1
  • D . 0

Reveal Solution Hide Solution

Correct Answer: A
Question #64

What is the expected output of the following code?

  • A . [2]
  • B . [3, 4, 5]
  • C . The program will cause an error.
  • D . [2, 3, 4, 5]

Reveal Solution Hide Solution

Correct Answer: B
Question #65

You develop a Python application for your company.

A list named employees contains 200 employee names, the last fi ve being company management. You need to slice the list to display all employees excluding management.

Which code segments can you use? (Choose two.)

  • A . employees[1:-5]
  • B . employees[0:-5]
  • C . employees[:-5]
  • D . employees[0:-4]
  • E . employees[1:-4]

Reveal Solution Hide Solution

Correct Answer: BC
Question #66

What is the expected output of the following code?

  • A . 112345
  • B . 234561
  • C . 234566
  • D . 123456

Reveal Solution Hide Solution

Correct Answer: C
Question #67

What is the expected output of the following code?

  • A . [1, 10, 3, 20, 5, 30, 7, 40, 9, 50, 60]
  • B . [1, 2, 10, 20, 30, 40, 50, 60]
  • C . The code is erroneous.
  • D . [10, 2, 20, 4, 30, 6, 40, 8, 50, 60]

Reveal Solution Hide Solution

Correct Answer: C
Question #68

What is the expected output of the following code?

  • A . 2
  • B . 1
  • C . The code is erroneous.
  • D . 3
  • E . 4

Reveal Solution Hide Solution

Correct Answer: C
Question #69

What is the expected output of the following code?

  • A . hellopeter
  • B . hello@Peter!!
  • C . hello@peter!!
  • D . None

Reveal Solution Hide Solution

Correct Answer: C
Question #70

Consider the following list.

data = [1, 5, 10, 19, 55, 30, 55, 99]

Which of the code snippets below would produce a new list like the following?

[1, 5, 10, 99]

A )

B )

C ) None of the above.

D )

E )

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D
  • E . Option E

Reveal Solution Hide Solution

Correct Answer: D

Question #71

What is the expected output of the following code?

  • A . 0
  • B . 1
  • C . False
  • D . True

Reveal Solution Hide Solution

Correct Answer: D
Question #72

What is the output of the following snippet?

  • A . [1, 2, 3, 1, 2, 3]
  • B . [3, 2, 1, 1, 2, 3]
  • C . [1, 1, 1, 1, 2, 3]
  • D . [1, 2, 3, 3, 2, 1]

Reveal Solution Hide Solution

Correct Answer: C
Question #73

Insert the correct snippet to convert the t tuple to a dictionary named d.

Expected output:

Code:

  • A . t >> d.dict
  • B . d = dict(t)
  • C . d.dict(t)
  • D . d = t(dict)

Reveal Solution Hide Solution

Correct Answer: B
Question #74

How many elements does the my_list list contain?

  • A . one
  • B . three
  • C . two

Reveal Solution Hide Solution

Correct Answer: C
Question #75

What is the expected output of the following code?

  • A . 72342
  • B . 74223
  • C . 42237

Reveal Solution Hide Solution

Correct Answer: B
Question #76

What is the expected output of the following code?

  • A . {(2, 3): 2}
  • B . {(1, 2): 1}
  • C . The code is erroneous.
  • D . 1

Reveal Solution Hide Solution

Correct Answer: D
Question #77

Take a look at the snippet and choose the true statement:

  • A . vals is longer than nums
  • B . nums is longer than vals
  • C . nums and vals have the same length
  • D . The snippet will cause a runtime error.

Reveal Solution Hide Solution

Correct Answer: C
Question #78

What is the expected output of the following code?

  • A . 3
  • B . The code is erroneous.
  • C . 6
  • D . 7

Reveal Solution Hide Solution

Correct Answer: C
Question #79

What would you insert instead of ???, so that the program checks for even numbers?

  • A . x % ‘even’ == True
  • B . x % 2 == 1
  • C . x % 2 == 0
  • D . x % x == 0
  • E . x % 1 == 2

Reveal Solution Hide Solution

Correct Answer: C
Question #80

What value will be assigned to the x variable?

  • A . 0
  • B . True
  • C . False
  • D . 1

Reveal Solution Hide Solution

Correct Answer: B

Question #81

What is the expected output of the following code?

x = 1 // 5 + 1 / 5

print(x)

  • A . 0
  • B . 0.2
  • C . 0.0
  • D . 0.4

Reveal Solution Hide Solution

Correct Answer: B
Question #82

An operator able to check whether two values are not equal is coded as:

  • A . <>
  • B . !=
  • C . =/=
  • D . not ==

Reveal Solution Hide Solution

Correct Answer: B
Question #83

The result of the following addition:

123 + 0.0

  • A . cannot be evaluated
  • B . is equal to 123
  • C . is equal to 123.0

Reveal Solution Hide Solution

Correct Answer: C
Question #84

What will be the output of the following code snippet?

print (3 / 5)

  • A . None of the above.
  • B . 0
  • C . 0.6
  • D . 6/10

Reveal Solution Hide Solution

Correct Answer: C
Question #85

What will be the output of the following code snippet?

  • A . 1
  • B . 4
  • C . 2
  • D . 3
  • E . None

Reveal Solution Hide Solution

Correct Answer: B
Question #86

What is the expected output of the following code?

x = 1 / 2 + 3 // 3 + 4 ** 2

print(x)

  • A . 17
  • B . 17.5
  • C . 8.5
  • D . 8

Reveal Solution Hide Solution

Correct Answer: B
Question #87

You develop a Python application for your company. You have the following code.

Which of the following expressions is equivalent to the expression in the function?

  • A . (a + b) * (c – d)
  • B . (a + (b * c)) – d)
  • C . (a + ((b * c) – d)
  • D . None of the above.

Reveal Solution Hide Solution

Correct Answer: D
Question #88

What is the output of the following code?

  • A . The output cannot be predicted.
  • B . 2
  • C . The program will cause an error.
  • D . 1

Reveal Solution Hide Solution

Correct Answer: B
Question #89

What is the expected output of the following code?

x = 28

y = 8

print(x / y)

print(x // y)

print(x % y)

  • A . 1 | 3.0
    2 | 3
    3 | 2
  • B . 1 | 3.5
    2 | 3
    3 | 4
  • C . 1 | 3
    2 | 3.5
    3 | 4
  • D . 1 | 3.5
    2 | 3.5
    3 | 2

Reveal Solution Hide Solution

Correct Answer: B
Question #90

Which of the following statements are true? (Choose two.)

  • A . The result of the / operator is always an integer value.
  • B . The ** operator uses right-sided binding.
  • C . The right argument of the % operator cannot be zero.
  • D . Addition precedes multiplication.

Reveal Solution Hide Solution

Correct Answer: BC

Question #91

Which of the following statements is false?

  • A . The right argument of the % operator can not be zero.
  • B . The ** operator has right-to-left associativity.
  • C . Multiplication precedes addition.
  • D . The result of the / operator is always an integer value.

Reveal Solution Hide Solution

Correct Answer: D
Question #92

What is the expected output of the following code?

print (1 // 2 * 3)

  • A . 4.5
  • B . 0.16666666666666666
  • C . 0.0
  • D . 0

Reveal Solution Hide Solution

Correct Answer: D
Question #93

What is the expected output of the following code?

  • A . True True
  • B . True False
  • C . False False
  • D . False True

Reveal Solution Hide Solution

Correct Answer: B
Question #94

The ** operator:

  • A . performs duplicated multiplication
  • B . does not exist
  • C . performs oating-point multiplication
  • D . performs exponentiation

Reveal Solution Hide Solution

Correct Answer: D
Question #95

Only one of the following statements is true – which one?

  • A . addition precedes multiplication
  • B . multiplication precedes addition
  • C . neither statement can be evaluated

Reveal Solution Hide Solution

Correct Answer: B
Question #96

The += operator, when applied to strings, performs:

  • A . Subtraction
  • B . Concatenation
  • C . Multiplication

Reveal Solution Hide Solution

Correct Answer: B
Question #97

What is the expected output of the following code?

  • A . 8
  • B . 7.0
  • C . 8.0
  • D . 9.0

Reveal Solution Hide Solution

Correct Answer: C
Question #98

Consider the following code.

The value eventually assigned to x is equal to:

  • A . 1
  • B . 0
  • C . True
  • D . False

Reveal Solution Hide Solution

Correct Answer: C
Question #99

What is the output of the following code?

  • A . The program will cause an error.
  • B . False
  • C . None
  • D . True

Reveal Solution Hide Solution

Correct Answer: D
Question #100

What is the expected output of the following code?

x = 1 + 1 // 2 + 1 / 2 + 2

print(x)

  • A . 3
  • B . 4.0
  • C . 4
  • D . 3.5

Reveal Solution Hide Solution

Correct Answer: D

Question #101

What value will be assigned to the x variable?

  • A . False
  • B . 0
  • C . 1
  • D . True

Reveal Solution Hide Solution

Correct Answer: A
Question #102

What is the expected output of the following code?

print(1 / 1)

  • A . 1
  • B . 1.0
  • C . This can not be predicted.
  • D . This can not be evaluated.

Reveal Solution Hide Solution

Correct Answer: B
Question #103

What is the expected output of the following code?

  • A . 1 | False
    2 | False
  • B . 1 | True
    2 | True
  • C . 1 | False
    2 | True
  • D . 1 | True
    2 | False

Reveal Solution Hide Solution

Correct Answer: C
Question #104

What is the expected output of the following code?

print(3 * ‘abc’ + ‘xyz’)

  • A . 3abcxyz
  • B . abcabcxyzxyz
  • C . abcabcabcxyz
  • D . abcxyzabcxyzabcxyz

Reveal Solution Hide Solution

Correct Answer: C
Question #105

What is the expected output of the following code?

  • A . 1 | True
    2 | False
    3 | True
    4 | False
  • B . 1 | False
    2 | False
    3 | True
    4 | True
  • C . 1 | False
    2 | True
    3 | True
    4 | True
  • D . 1 | False
    2 | True
    3 | False
    4 | True

Reveal Solution Hide Solution

Correct Answer: B
Question #106

What would you insert instead of ???, so that the program prints True to the monitor?

  • A . x < y
  • B . x is not y
  • C . x is y
  • D . x != y

Reveal Solution Hide Solution

Correct Answer: C
Question #107

What is the expected output of the following code?

  • A . 123
  • B . 122
  • C . 321
  • D . 213

Reveal Solution Hide Solution

Correct Answer: A
Question #108

What is the expected output of the following code?

  • A . 1
  • B . 2
  • C . 4
  • D . 3

Reveal Solution Hide Solution

Correct Answer: A
Question #109

What is the data type of x, y, z after executing the following snippet?

  • A . int, int, int
  • B . x is int, y and z are invalid declarations
  • C . int, str, int
  • D . int, str, str

Reveal Solution Hide Solution

Correct Answer: D
Question #110

What is the expected output of the following code?

x = 2

y = 6

x += 2 ** 3

x //= y // 2 // 3

print(x)

  • A . 9
  • B . 10
  • C . 0
  • D . 11

Reveal Solution Hide Solution

Correct Answer: B

Question #111

The result of the following division:

  • A . cannot be evaluated
  • B . is equal to 1.0
  • C . is equal to 1
  • D . cannot be predicted

Reveal Solution Hide Solution

Correct Answer: B
Question #112

What is the expected output of the following code?

  • A . 7
  • B . The code is erroneous.
  • C . 6.0
  • D . 7.0
  • E . 6

Reveal Solution Hide Solution

Correct Answer: D
Question #113

What is the expected output of the following code?

print(‘Mike’ > ‘Mikey’)

  • A . False
  • B . True
  • C . 1
  • D . 0

Reveal Solution Hide Solution

Correct Answer: A
Question #114

Which of the following is the correct order of operator precedence?

  • A . Exponents –
    Unary positive, negative, not –
    Parentheses –
    Multiplication and Division –
    Addition and Subtraction –
    And
  • B . Parentheses –
    Exponents –
    Unary positive, negative, not –
    Addition and Subtraction –
    Multiplication and Division –
    And
  • C . Parentheses –
    Exponents –
    Unary positive, negative, not –
    Multiplication and Division –
    Addition and Subtraction –
    And
  • D . Exponents –
    Unary positive, negative, not –
    Multiplication and Division –
    Addition and Subtraction –
    And –
    Parentheses

Reveal Solution Hide Solution

Correct Answer: C
Question #115

What is the result of the following operation?

  • A . 2.0
  • B . 11.0
  • C . The operation is illegal in Python
  • D . 2

Reveal Solution Hide Solution

Correct Answer: A
Question #116

Consider the following code.

Which statement will print True to the monitor? (Choose two.)

  • A . print(languages == more_languages)
  • B . print(languages is more_languages)
  • C . print(more_languages is extra_languages)
  • D . print(languages is extra_languages)

Reveal Solution Hide Solution

Correct Answer: AC
Question #117

Which expression evaluates to 7?

  • A . 9%3+7
  • B . 9-3*7
  • C . 9//3-7
  • D . 9/3*7

Reveal Solution Hide Solution

Correct Answer: A
Question #118

The // operator:

  • A . performs integer division
  • B . performs regular division
  • C . does not exist

Reveal Solution Hide Solution

Correct Answer: A
Question #119

Which of the following statements are correct? (Choose two.)

  • A . 7 + False evaluates to False
  • B . True or False evaluates to True
  • C . True + 1 evaluates to 2
  • D . True and False evaluates to True
  • E . type(”) returns <class ‘bool’>

Reveal Solution Hide Solution

Correct Answer: BC
Question #120

What is the output of the following snippet?

  • A . 25.0
  • B . The snippet will cause an execution error.
  • C . 17.0
  • D . 17

Reveal Solution Hide Solution

Correct Answer: C

Question #121

What is the expected output of the following code?

  • A . 1 | False
    2 | True
    3 | False
    4 | True
  • B . 1 | False
    2 | True
    3 | True
    4 | True
  • C . 1 | False
    2 | True
    3 | True
    4 | False
  • D . 1 | False
    2 | False
    3 | True
    4 | True

Reveal Solution Hide Solution

Correct Answer: B
Question #122

Evaluate the following Python arithmetic expression:

(3*(1+2) **2-(2**2) *3)

What is the result?

  • A . 13
  • B . 3
  • C . 69
  • D . 15

Reveal Solution Hide Solution

Correct Answer: D
Question #123

What value will be assigned to the x variable?

  • A . 1
  • B . False
  • C . True

Reveal Solution Hide Solution

Correct Answer: C
Question #124

Consider the following code.

What does the second assignment do?

  • A . It shortens the list.
  • B . It reverses the list.
  • C . It doesn’t change the list.
  • D . It extends the list.

Reveal Solution Hide Solution

Correct Answer: B
Question #125

An operator able to check whether two values are equal, is coded as:

  • A . ==
  • B . ===
  • C . is
  • D . =

Reveal Solution Hide Solution

Correct Answer: A
Question #126

What will be the output of the following snippet?

  • A . 00
  • B . 11
  • C . 01
  • D . 10

Reveal Solution Hide Solution

Correct Answer: D
Question #127

What is the expected output of the following code?

  • A . 2
  • B . 0
  • C . 1
  • D . 3

Reveal Solution Hide Solution

Correct Answer: A
Question #128

Consider the following code.

x = oat (‘23.42’)

Which of the following expressions will evaluate to 2?

  • A . int(x) + False
  • B . bool(x) + True
  • C . str(x)
  • D . bool(x)

Reveal Solution Hide Solution

Correct Answer: B
Question #129

What is the expected output of the following code?

print (1 // 2)

  • A . 0.5
  • B . 0.0
  • C . None of the above.
  • D . 0

Reveal Solution Hide Solution

Correct Answer: D
Question #130

What is the result of the following code?

  • A . 1
  • B . 2
  • C . 5
  • D . 3

Reveal Solution Hide Solution

Correct Answer: B

Question #131

What is the expected output of the following code?

  • A . 1 | True
    2 | True
    3 | False
    4 | False
  • B . 1 | True
    2 | False
    3 | False
    4 | False
  • C . 1 | True
    2 | False
    3 | False
    4 | True
  • D . 1 | True
    2 | False
    3 | True
    4 | False

Reveal Solution Hide Solution

Correct Answer: B
Question #132

The expression:

‘mike’ > ‘Mike’

is

  • A . erroneous
  • B . true
  • C . false

Reveal Solution Hide Solution

Correct Answer: B
Question #133

You are writing a Python program that evaluates an arithmetic formular.

The formular is described as b equals a multiplied by negative one, then raised to the second power, where a is the value that will be input and b is the result. a = eval (input (‘Enter a number for the equation: ‘))

Which of the following is a valid expression for the given requirement?

  • A . b = (-a) ** 2
  • B . b = (a-) ** 2
  • C . b = (a) ** -2
  • D . b = -(a) ** 2

Reveal Solution Hide Solution

Correct Answer: A
Question #134

What is the expected output of the following code?

print (2 ** 3 ** 2 ** 1)

  • A . 64
  • B . 16
  • C . 128.0
  • D . The code is erroneous.
  • E . 16.0
  • F . 512

Reveal Solution Hide Solution

Correct Answer: F
Question #135

Which of the following code snippets will print True to the monitor? (Choose two.)

A )

B )

C )

D )

E )

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D
  • E . Option E

Reveal Solution Hide Solution

Correct Answer: AD
Question #136

What value will be assigned to the x variable?

  • A . False
  • B . 1
  • C . 0
  • D . True

Reveal Solution Hide Solution

Correct Answer: D
Question #137

The ** operator …

  • A . does not exist.
  • B . performs fl oating-point multiplication.
  • C . performs duplicated multiplication.
  • D . performs exponentiation.

Reveal Solution Hide Solution

Correct Answer: D
Question #138

Right-sided binding means that the following expression

will be evaluated:

  • A . from right to left
  • B . in random order
  • C . from left to right

Reveal Solution Hide Solution

Correct Answer: A
Question #139

What is the expected output of the following code?

print (type (1 / 2))

  • A . <type ‘double’>
  • B . <type ‘int’>
  • C . <type ‘number’>
  • D . <type ‘tuple’>
  • E . <type ‘ oat’>

Reveal Solution Hide Solution

Correct Answer: E
Question #140

What is the expected output of the following code?

  • A . 01
  • B . 10
  • C . The code is erroneous.
  • D . 00
  • E . 11

Reveal Solution Hide Solution

Correct Answer: E

Question #141

What is the output of the following code?

  • A . 2x
  • B . 22
  • C . The program will cause an error.
  • D . 4

Reveal Solution Hide Solution

Correct Answer: B
Question #142

What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively?

  • A . 333333
  • B . 18
  • C . 36
  • D . 666

Reveal Solution Hide Solution

Correct Answer: A
Question #143

What is the expected output of the following code?

  • A . The code is erroneous.
  • B . TRUE
  • C . FALSE
  • D . None of the above.

Reveal Solution Hide Solution

Correct Answer: B
Question #144

What is the expected output of the following code if the user enters 2 and 4?

  • A . 1.0
  • B . 4.0
  • C . 2.0
  • D . 0.0

Reveal Solution Hide Solution

Correct Answer: C
Question #145

What is the expected output of the following code?

x = 4.5

y = 2

print (x // y)

  • A . 2.5
  • B . 2
  • C . 2.25
  • D . 2.0

Reveal Solution Hide Solution

Correct Answer: D
Question #146

The digraph written as #! is used to:

  • A . tell an MS Windows OS how to execute the contents of a Python le.
  • B . tell a Unix or Unix-like OS how to execute the contents of a Python le.
  • C . create a docstring.
  • D . make a particular module entity a private one.

Reveal Solution Hide Solution

Correct Answer: B
Question #147

What are the four fundamental elements that make a language?

  • A . An alphabet, a lexis, a syntax, and semantics
  • B . An alphabet, morphology, phonetics, and semantics
  • C . An alphabet, a lexis, phonetics, and semantics
  • D . An alphabet, phonetics, phonology, and semantics

Reveal Solution Hide Solution

Correct Answer: A
Question #148

What do you call a tool that lets you launch your code step-by-step and inspect it at each moment of execution?

  • A . An editor
  • B . A debugger
  • C . A console

Reveal Solution Hide Solution

Correct Answer: B
Question #149

What will be the output of the following code snippet?

  • A . 12
  • B . 22
  • C . 11
  • D . 21

Reveal Solution Hide Solution

Correct Answer: D
Question #150

What is the expected output of the following code?

  • A . 121
  • B . 212
  • C . 112
  • D . 122

Reveal Solution Hide Solution

Correct Answer: C

Question #151

Python is an example of:

  • A . a machine language
  • B . a natural language
  • C . a high-level programming language

Reveal Solution Hide Solution

Correct Answer: C
Question #152

What is the expected output of the following code?

  • A . 0
  • B . 1
  • C . The code is erroneous.
  • D . 2

Reveal Solution Hide Solution

Correct Answer: B
Question #153

Which of the following variable names are illegal? (Choose two.)

  • A . True
  • B . true
  • C . and
  • D . TRUE

Reveal Solution Hide Solution

Correct Answer: AC
Question #154

What is CPython?

  • A . It’s a programming language that is a superset of the C language, designed to produce Python-like performance with code written in C.
  • B . It’s a default, reference implementation of the Python language, written in C.
  • C . It’s a programming language that is a superset of the Python, designed to produce C-like performance with code written in Python.
  • D . It’s a default, reference implementation of the C language, written in Python.

Reveal Solution Hide Solution

Correct Answer: B
Question #155

Which of the following variable names is illegal?

  • A . In
  • B . IN
  • C . in_
  • D . in

Reveal Solution Hide Solution

Correct Answer: D
Question #156

What is the default value of encoding in the string function encode()?

  • A . qwerty
  • B . ascii
  • C . utf-16
  • D . utf-8

Reveal Solution Hide Solution

Correct Answer: D
Question #157

What is machine code?

  • A . A medium-level programming language consisting of the assembly code designed for the computer processor
  • B . A low-level programming language consisting of binary digits/bit that the computer reads and understands
  • C . A high-level programming language consisting of instruction lists that humans can read and understand
  • D . A low-level programming language consisting of hexadecimal digits that make up high-level language instructions

Reveal Solution Hide Solution

Correct Answer: B
Question #158

The pyc fi le contains …

  • A . a Python interpreter.
  • B . Python source code.
  • C . compiled Python bytecode.
  • D . a Python compiler.

Reveal Solution Hide Solution

Correct Answer: C
Question #159

Select the true statements: (Choose two.)

  • A . You can use keywords as variable names in Python
  • B . You can use keywords as function names in Python
  • C . You cannot use keywords as variable names in Python
  • D . You cannot use keywords as function names in Python

Reveal Solution Hide Solution

Correct Answer: CD
Question #160

The escape character owes its name to the fact that it:

  • A . cannot be caught due to its high speed
  • B . escapes from source les into the computer memory
  • C . changes the meaning of the character next to it

Reveal Solution Hide Solution

Correct Answer: C
Exit mobile version