PCEP-30-02 Exam Questions
392 real PCEP-30-02 exam questions with expert-verified answers and explanations. Page 5 of 8.
- Question #201
What is the output of the following snippet? def fun(in=2, out=3): return in * out print(fun(3))
- Question #202
What is the expected output of the following code? def fun(n): n **= n return n print(fun(3))
- Question #203
A function definition:
- Question #204
Which of the following items are present in the function header?
- Question #205
```python num = 1 def func(): num = 3 print(num, end=' ') func() print(num) ``` What is the output of the following snippet?
- Question #206
Which of the following function headers is correct?
- Question #207
```python def func(x, y): if x == y: return x else: return func(x, y-1) print(func(0, 3)) ``` What is the output of the following snippet?
- Question #208
```python def func(item): item += [1] data = [1, 2, 3, 4] func(data) print(len(data)) ``` What is the expected output of the following code?
- Question #209
The meaning of the keyword parameter is determined by:
- Question #210
Which of the following function definition does not return any value?
- Question #211
Select the true statement:
- Question #212
```python def any(): var = 1 print(var + 1, end='') var = 1 any() print(var) ``` What is the output of the following snippet?
- Question #213
```python def func(x): global y y = x * x return y func(2) print(y) ``` What is the expected output of the following code?
- Question #214
```python def func(x, y=2): num = 1 for i in range(y): num = num * x return num print(func(4)) print(func(4, 4)) ``` What is the expected output of the following code?
- Question #215
A function parameter is a kind of variable accessible:
- Question #216
```python def test(x=1, y=2): x = x + y y += 1 print(x, y) test() ``` What is the expected output of the following code?
- Question #217
```python def test(x, y=23, z=10): print('x is', x, ',and y is', y, ',and z is', z) test(3, 7) test(42, z=24) test(z=60, x=100) ``` What is the expected output of the following cod...
- Question #218
```python def fun(n): x = [] for i in range(n): x.append(i) return x print(fun(4)) ``` What is the expected output of the following code?
- Question #219
What is the expected output of the following code? ```python def func(n): s = '**' for i in range(n): s += s yield s for x in func(2): print(x, end='') ```
- Question #220
What is the expected output of the following code? ```python def func(a, b): return a ** a print(func(2)) ```
- Question #221
Consider the following code. ```python def func(x=0): return x ``` With sentence describes the function the best? A function defined like function()...
- Question #222
What is the expected output of the following code? ```python def func(): print(x + 1, end=' ') x = 1 func() print(x) ```
- Question #223
What is the expected output of the following code? ```python def func(x): if x == 0: return 0 return x + func(x - 1) print(func(3)) ```
- Question #224
The meaning of the positional parameter is determined by its:
- Question #225
What is the expected output of the following code? ```python def func(x, y, z): return x + 4 * y + 5 * z print(func(1, z=2, y=3)) ```
- Question #226
What is the output of the following snippet? ```python def fun(inp=2, out=3): return inp * out print(fun(out=2)) ```
- Question #227
A variable defined outside a function:
- Question #228
What is the expected output of the following code? ```python def func(x): if x % 2 == 0: return 1 else: return 2 print(func(func(2))) ```
- Question #229
What is the expected output of the following code? ```python def func(x=2, y=3): return x * y print(func(y=2)) ```
- Question #230
Which of the approachable except: branches is taken into consideration when an exception occurs?
- Question #231
What is the expected behavior of the following program? ```python try: print(5/0) break except: print("Sorry, something went wrong...") except (ValueError, ZeroDivisionError): prin...
- Question #232
What will happen when you attempt to run the following code? ```python print("Hello, World!") ```
- Question #233
What is the output of the following program if the user enters kangaroo at the first prompt and 0 at the second prompt? ```python try: first_prompt = input("Enter the first value:...
- Question #234
QUESTION 261 The unnamed except block ...
- Question #235
QUESTION 262 What is the output of the following code? try: value = input("Enter a value: ") print(value/value) except ValueError: print("Bad input...") except ZeroDivisionError: p...
- Question #236
QUESTION 264 What is the expected output of the following code? num = '7' * '7' print(num)
- Question #237
QUESTION 265 The part of your code where the handling of an exception takes place should be placed inside:
- Question #238
QUESTION 266 Select the true statements about the try-except block in relation to the following example. (Choose three.) try: # Some code is here... except: # Some code is here...
- Question #239
QUESTION 267 The part of your code where you think an exception may occur should be placed inside:
- Question #240
QUESTION 268 What is the expected behavior of the following program? foo = (1, 2, 3) foo.index(0)
- Question #241
QUESTION 269 What is the expected result of the following code? try: raise Exception except: print("c") except BaseException: print("a") except Exception: print("b")
- Question #242
QUESTION 270 Which of the following snippets shows the correct way of handling multiple exceptions in a single except clause?
- Question #243
QUESTION 271 The following statement ... assert x == 0
- Question #244
QUESTION 272 What is the expected output of the following code? try: raise BaseException: except BaseException: print('1') except Exception: print('2') except: print('3')
- Question #245
QUESTION 273 What is the expected behavior of the following program if the user enters 0? value = input("Enter a value: ") print(10/value)
- Question #246
QUESTION 274 An assertion can be used to:
- Question #247
What is the expected output of the following code? print('x', 'y', 'z', sep='sep')
- Question #248
The ABC Company is building a basketball court for its employees to improve company morale. You are creating a Python program that employees can use to keep track of their average...
- Question #249
Consider the following code. 1 start = input('How old were you at the time of joining?') 2 now = input('How old are you today?') Which of the following statements will print the ri...
- Question #250
Consider the following code. 1 data = eval(input('Input: ')) 2 print('Output: ', data) Which of the inputs below would produce the specified output?