Exam Code : PCEP-30-01
Exam Name : Certified Entry-Level Python Programmer
Vendor Name :
"AICPA"
PCEP-30-01 Dumps
PCEP-30-01 Braindumps PCEP-30-01 Real Questions PCEP-30-01 Practice Test PCEP-30-01 Actual Questions
Certified Entry-Level Python Programmer
https://killexams.com/pass4sure/exam-detail/PCEP-30-01
Question: 34
A function definition starts with the keyword:
def
function
fun
Try it yourself:
def my_first_function(): print(‘Hello’) my_first_function() # Hello
https://www.w3schools.com/python/python_functions.asp
Question: 35
Consider the following code snippet: w = bool(23)
x = bool(”)
y = bool(‘ ‘)
z = bool([False])
Which of the variables will contain False?
z
x
y
w
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: 36
Assuming that the tuple is a correctly created tuple,
the fact that tuples are immutable means that the following instruction: my_tuple[1] = my_tuple[1] + my_tuple[0]
can be executed if and only if the tuple contains at least two elements
is illegal
may be illegal if the tuple contains strings
is fully correct
Try it yourself: my_tuple = (1, 2, 3)
my_tuple[1] = my_tuple[1] + my_tuple[0]
# TypeError: ‘tuple’ object does not support item assignment A tuple is immutable and therefore you cannot
assign a new value to one of its indexes.
Question: 37
You develop a Python application for your company. You have the following code.
def main(a, b, c, d): value = a + b * c – d return value
Which of the following expressions is equivalent to the expression in the function? A. (a + b) * (c – d)
a + ((b * c) – d)
None of the above. D. (a + (b * c)) – d
Topics: addition operator multiplication operator subtraction operator operator precedence
Try it yourself:
def main(a, b, c, d): value = a + b * c – d # 3
# value = (a + (b * c)) – d # 3
# value = (a + b) * (c – d) # -3
# value = a + ((b * c) – d) # 3 return value
print(main(1, 2, 3, 4)) # 3
This question is about operator precedence
The multiplication operator has the highest precedence and is therefore executed first. That leaves the addition operator and the subtraction operator
They both are from the same group and therefore have the same precedence. That group has a left-to-right associativity.
The addition operator is on the left and is therefore executed next. And the last one to be executed is the subtraction operator
Question: 38
Which of the following variable names are illegal? (Select two answers)
TRUE
True
true
and
Topics: variable names keywords True and Try it yourself:
TRUE = 23
true = 42
# True = 7 # SyntaxError: cannot assign to True
# and = 7 # SyntaxError: invalid syntax You cannot use keywords as variable names.
Question: 39
Which of the following for loops would output the below number pattern?
for i in range(0, 5): print(str(i) * 5)
for i in range(1, 6): print(str(i) * 5)
for i in range(1, 6): print(i, i, i, i, i)
for i in range(1, 5): print(str(i) * 5)
Topics: for range() str() multiply operator string concatenation Try it yourself:
for i in range(1, 6): print(str(i) * 5)
""" 11111
22222
33333
44444
55555 """
print(‘———-‘) for i in range(0, 5): print(str(i) * 5)
"""
"""
print(‘———-‘) for i in range(1, 6): print(i, i, i, i, i)
"""
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5 """
print(‘———-‘) for i in range(1, 5): print(str(i) * 5)
""" 11111
22222
33333
44444 """
You need range (1, 6)
because the start value 1 is inclusive and the end value 6 is exclusive. To get the same numbers next to each other (without a space between them) you need to make a string and then use the multiply operator string concatenation
The standard separator of the print() function is one space. print(i, i, i, i, i) gives you one space between each number. It would work with print(i, i, i, i, i, sep=”) but that answer is not offered here.
The digraph written as #! is used to:
tell a Unix or Unix-like OS how to execute the contents of a Python file.
create a docstring.
make a particular module entity a private one.
tell an MS Windows OS how to execute the contents of a Python file.
This is a general UNIX topic. Best read about it here:
https://en.wikipedia.org/wiki/Shebang_(Unix)