Certification Practice Test | PDF Questions | Actual Questions | Test Engine | Pass4Sure
PCEP-30-02 : PCEP - Certified Entry-Level Python Programmer Exam
Python PCEP-30-02 Questions & Answers
Full Version: 149 Q&A
PCEP-30-02 Dumps
PCEP-30-02 Braindumps
PCEP-30-02 Real Questions
PCEP-30-02 Practice Test
PCEP-30-02 Actual Questions
Python
PCEP-30-02
PCEP - Certified Entry-Level Python Programmer
https://killexams.com/pass4sure/exam-detail/PCEP-30-02
Question: 33
Consider the following code snippet:
w = bool(23)
x = bool('')
y = bool(' ')
z = bool([False])
Which of the variables will contain False?
A. z
B. x
C. y
D. w
Answer: B
Explanation:
Topic: type casting with bool()
Try it yourself:
print(bool(23)) # True
print(bool('')) # False
print(bool(' ')) # True
print(bool([False])) # True
The list with the value False is not empty and therefore it becomes True
The string with the space also contain one character
and therefore it also becomes True
The values that become False in Python are the following:
print(bool('')) # False
print(bool(0)) # False
print(bool(0.0)) # False
print(bool(0j)) # False
print(bool(None)) # False
print(bool([])) # False
print(bool(())) # False
print(bool({})) # False
print(bool(set())) # False
print(bool(range(0))) # False
Question: 34
What is the expected output of the following code?
def func(num):
res = '*'
for _ in range(num):
res += res
return res
for x in func(2):
print(x, end='')
A. **
B. The code is erroneous.
C. *
D. ****
Answer: D
Explanation:
Topics: def return for
Try it yourself:
def func(num):
res = '*'
for _ in range(num):
res += res
return res
for x in func(2):
print(x, end='') # ****
# print(x, end='-') # *-*-*-*-
print()
print(func(2)) # ****
The for loop inside of the function will iterate twice.
Before the loop res has one star.
In the first iteration a second star is added.
res then has two stars.
In the second iteration two more stars are added to those two star and res will end up with four stars.
The for loop outside of the function will just iterate through the string and print every single star.
You could get that easier by just printing the whole return value.
Question: 35
What is the expected output of the following code?
num = 1
def func():
num = num + 3
print(num)
func()
print(num)
A. 4 1
B. 4 4
C. The code is erroneous.
D. 1 4
E. 1 1
Answer: C
Explanation:
Topics: def shadowing
Try it yourself:
num = 1
def func():
# num = num + 3 # UnboundLocalError: ...
print(num)
func()
print(num)
print('----------')
num2 = 1
def func2():
x = num2 + 3
print(x) # 4
func2()
print('----------')
num3 = 1
def func3():
num3 = 3 # Shadows num3 from outer scope
print(num3) # 3
func3()
A variable name shadows into a function.
You can use it in an expression like in func2()
or you can assign a new value to it like in func3()
BUT you can not do both at the same time like in func()
There is going to be the new variable num
and you can not use it in an expression before its first assignment.
Question: 36
The result of the following addition:
123 + 0.0
A. cannot be evaluated
B. is equal to 123.0
C. is equal to 123
Answer: B
Explanation:
Topics: addition operator integer float
Try it yourself:
print(123 + 0.0) # 123.0
If you have an arithmetic operation with a float,
the result will also be a float.
Question: 37
What is the expected output of the following code?
print(list('hello'))
A. None of the above.
B. hello
C. [h, e, l, l, o]
D. ['h', 'e', 'l', 'l', 'o']
E. ['h' 'e' 'l' 'l' 'o']
Answer: D
Explanation:
Topic: list()
Try it yourself:
print(list('hello')) # ['h', 'e', 'l', 'l', 'o']
A string is a sequence of characters
and works very fine with the list() function.
The result is a list of strings, in which every character is a string of its own.
Question: 38
What is the default return value for a function
that does not explicitly return any value?
A. int
B. void
C. None
D. Null
E. public
Answer: C
Explanation:
Topic: return
Try it yourself:
def func1():
pass
print(func1()) # None
def func2():
return
print(func2()) # None
If a function does not have the keyword return the function will return the value None
The same happens if there is no value after the keyword return
Question: 39
Which of the following lines correctly invoke the function defined below:
def fun(a, b, c=0):
# Body of the function.
(Select two answers)
A. fun(0, 1, 2)
B. fun(b=0, a=0)
C. fun(b=1)
D. fun()
Answer: A,B
Explanation:
Topics: functions positional parameters keyword parameters
Try it yourself:
def fun(a, b, c=0):
# Body of the function.
pass
fun(b=0, a=0)
fun(0, 1, 2)
# fun() # TypeError: fun() missing 2 required
# positional arguments: 'a' and 'b'
# fun(b=1) # TypeError: fun() missing 1 required
# positional argument: 'a'
Only the parameter c has a default value.
Therefore you need at least two arguments.
Question: 40
What is the expected output of the following code?
x = '''
print(len(x))
A. 1
B. 2
C. The code is erroneous.
D. 0
Answer: A
Explanation:
Topics: len() escaping
Try it yourself:
print(len(''')) # 1
The backslash is the character to escape another character.
Here the backslash escapes the following single quote character.
Together they are one character.
Question: 41
Which of the following statements are true? (Select two answers)
A. The ** operator uses right-sided binding.
B. The result of the / operator is always an integer value.
C. The right argument of the % operator cannot be zero.
D. Addition precedes multiplication.
Answer: A,B,D
Explanation:
Topics: exponentiation/power operator right-sided binding
Try it yourself:
print(4 ** 3 ** 2) # 262144
print(4 ** (3 ** 2)) # 262144
print(4 ** 9) # 262144
print(262144) # 262144
# print(7 % 0) # ZeroDivisionError
If you have more than one power operators
next to each other, the right one will be executed first. https://docs.python.org/3/reference/expressions.html#the-power-
operator To check the rest of a modulo operation,
Python needs to divide the first operand by the second operand.
And like in a normal division, the second operand cannot be zero.
Question: 42
What do you call a tool that lets you lanch your code step-by-step and inspect it at each moment of execution?
A. A debugger
B. An editor
C. A console
Answer: A
Explanation:
Topic: debugger
https://en.wikipedia.org/wiki/Debugger
Question: 43
What is the expected output of the following code?
list1 = [1, 3]
list2 = list1
list1[0] = 4
print(list2)
A. [1, 4]
B. [4, 3]
C. [1, 3, 4]
D. [1, 3]
Answer: B
Explanation:
Topics: list reference of a mutable data type
Try it yourself:
list1 = [1, 3]
list2 = list1
list1[0] = 4
print(list2) # [4, 3]
print(id(list1)) # e.g. 140539383947452
print(id(list2)) # e.g. 140539383947452 (the same number)
A list is mutable.
When you assign it to a different variable, you create a reference of the same object.
If afterwards you change one of them, the other one is changed too.
Question: 44
How many stars will the following code print to the monitor?
i = 0
while i <= 3:
i += 2
print('*')
A. one
B. zero
C. two
D. three
Answer: C
Explanation:
Topic: while
Try it yourself:
i = 0
while i <= 3: # i=0, i=2
i += 2
print('*')
"""
*
*
"""
In the first iteration of the while loop i is 0
i becomes 2 and the first star is printed.
In the second iteration of the while loop i is 2
i becomes 4 and the second star is printed.
i is 4 and therefore 4 <= 3 is False what ends the while loop.
Question: 45
What is the expected output of the following code if the user enters 2 and 4?
x = input()
y = input()
print(x + y)
A. 4
B. 6
C. 24
D. 2
Answer: C
Explanation:
Topics: input() plus operator string concatenation
Try it yourself:
# x = input()
# y = input()
x, y = '2', '4' # Just for convenience
print(x + y) # 24
As always the input() function return a string.
Therefore string concatenation takes place and the result is the string 24
User: Aaron***** killexams.com is the best test preparation available on the market! I took and passed my PCEP-30-02 exam with flying colors, with only one question being unseen in the exam. The practice tests data is incredibly useful, making the product more than just a brain-dump. Coupled with traditional memorization, the exam simulator is a valuable tool in advancing ones career. |
User: Margaret***** As an IT professional, I find it challenging to prepare for the pcep-30-02 certification exam due to my busy work schedule. However, Killexams.com Questions and Answers practice tests helped me prepare for the exam. I was surprised by how quickly I was able to complete all the questions. The questions were straightforward, and the reference guide was excellent. I scored 939 marks on the pcep-30-02 certification exam, which was a great achievement for me. I am grateful to Killexams.com for their support. |
User: Polly***** Before discovering the platform, I was unsure of the internet abilities. However, after creating an account, I experienced a whole new world that led to my successful streak. To prepare for my exams, I received specific and comprehensive test questions and answers and a fixed pattern to follow. These materials helped me achieve success in my exam, which was a great feat. I thank the platform for their assistance. |
User: Nelya***** After researching the PCEP-30-02 exam and considering it, I feel that I made the right choice in taking it. With the help of killexams.com practice tests, I was able to pass the exam with an impressive 89% mark, which has opened up several job opportunities for me. I am grateful to killexams.com for helping me improve my knowledge and achieve this success. |
User: Marie***** I am glad that I discovered Killexams.com online and purchased their pcep-30-02 package days before my exam. The exam simulator was very helpful and covered all the objectives and questions tested in the pcep-30-02 exam. While some might question paying for a brain dump, I can confidently say that Killexams.com is worth every penny. |
Features of iPass4sure PCEP-30-02 Exam
- Files: PDF / Test Engine
- Premium Access
- Online Test Engine
- Instant download Access
- Comprehensive Q&A
- Success Rate
- Real Questions
- Updated Regularly
- Portable Files
- Unlimited Download
- 100% Secured
- Confidentiality: 100%
- Success Guarantee: 100%
- Any Hidden Cost: $0.00
- Auto Recharge: No
- Updates Intimation: by Email
- Technical Support: Free
- PDF Compatibility: Windows, Android, iOS, Linux
- Test Engine Compatibility: Mac / Windows / Android / iOS / Linux
Premium PDF with 149 Q&A
Get Full VersionAll Python Exams
Python ExamsCertification and Entry Test Exams
Complete exam list