PCEP-30-02 Practice Exam — Free 474+ Questions | ExamCademy474Practice Questions
3Study Modes
FreeTo Get Started
Question 2
Ask AstroTutor
Ad
Want a break from the ads?
Become a Supporter and enjoy a completely ad-free experience, plus unlock Learn Mode, Exam Mode, AstroTutor AI, and more.
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
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
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
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
What is the expected output of the following code?

What is the expected output of the following code?

- A [1, 3]
- B [1, 4]
- C [4, 3]
- D [1, 3, 4]
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']
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.
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]
What value will be assigned to the x variable?

What is the expected output of the following code?

- A 0 1
- B 1 0
- C The code is erroneous.
- D 0 0
- E 1 1
What is the expected output of the following code?

- A The code is erroneous.
- B 2
- C 3
- D 1
What is the expected behavior of the following program?

- A The program will cause a ValueError exception and output a default error message.
- B The program will cause a SyntaxError exception.
- C The program will cause a ZeroDivisionError exception and output a default error message.
- D The program will cause a ValueError exception and output the following message: Too bad...
- E The program will raise an exception handled by the first except block.
What is the expected output of the following code?

What is the expected output of the following code?

- A 1 | Hello2 | Hello
- B 1 | Hello2 | Hello3 | Hello
- C 1 | Hello2 | Hello3 | Hello4 | Hello
- D An infinite loop.
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.
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']
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
What is the output of the following snippet?

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]
What will be the output of the following code snippet?

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"])
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()
What is the expected output of the following code?

- A The code is erroneous.
- B 1
- C 0
- D None
What is the output of the following snippet?

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