Python Institute PCEP-30-01 Certified Entry-Level Python Programmer Online Training
Python Institute PCEP-30-01 Online Training
The questions for PCEP-30-01 were last updated at Nov 22,2024.
- Exam Code: PCEP-30-01
- Exam Name: Certified Entry-Level Python Programmer
- Certification Provider: Python Institute
- Latest update: Nov 22,2024
What are the four fundamental elements that make a language?
- A . An alphabet, phonetics, phonology, and semantics
- B . An alphabet, a lexis, phonetics, and semantics
- C . An alphabet, morphology, phonetics, and semantics
- D . An alphabet, a lexis, a syntax, and semantics
D
Explanation:
Topics: language alphabet lexis syntax semantics
We can say that each language (machine or natural, it doesn’t matter)
consists of the following elements:
An alphabet:
a set of symbols used to build words of a certain language (e.g., the Latin alphabet for English,
the Cyrillic alphabet for Russian, Kanji for Japanese, and so on)
A lexis:
(aka a dictionary) a set of words the language offers its users
(e.g., the word "computer" comes from the English language dictionary, while "cmoptrue" doesn’t;
the word "chat" is present both in English and French dictionaries,
but their meanings are different)
A syntax:
a set of rules (formal or informal, written or felt intuitively)
used to determine if a certain string of words forms a valid sentence
(e.g., "I am a python" is a syntactically correct phrase, while "I a python am" isn’t)
Semantics:
a set of rules determining if a certain phrase makes sense
(e.g., "I ate a doughnut" makes sense, but "A doughnut ate me" doesn’t)
What will be the output of the following code snippet?
x = 1
y = 2
z = x
x = y
y = z
print (x, y)
- A . 1 2
- B . 2 1
- C . 1 1
- D . 2 2
B
Explanation:
Topic: copying an immutable object by assigning
Try it yourself:
x = 1
y = 2
z = x
print(z) # 1
x = y
print(x) # 2
y = z
print(y) # 1
print(x, y) # 2 1
Integer is an immutable data type.
The values get copied from one variable to another.
In the end x and y changed their values.
Python is an example of:
- A . a machine language
- B . a high-level programming language
- C . a natural language
B
Explanation:
Topic: high-level programming language
https://en.wikipedia.org/wiki/Python_(programming_language)
What will be the output of the following code snippet?
print(3 / 5)
- A . 6/10
- B . 0.6
- C . 0
- D . None of the above.
B
Explanation:
Topic: division operator
Try it yourself:
print(3 / 5) # 0.6
print(4 / 2) # 2.0
The division operator does its normal job.
And remember the division operator ALWAYS returns a float.
Strings in Python are delimited with:
- A . backslashes (i.e., )
- B . double quotes (i.e., ") or single quotes (i.e., ‘)
- C . asterisks (i.e., *)
- D . dollar symbol (i.e., $)
B
Explanation:
Topics: strings quotes
Try it yourself:
print("Hello") # Hello
print(‘World’) # World
Unlike in other programming languages, in Python double quotes and single quotes are synonyms for each other.
You can use either one or the other.
The result is the same.
What will happen when you attempt to run the following code?
print(Hello, World!)
- A . The code will raise the SyntaxError exception.
- B . The code will raise the TypeError exception.
- C . The code will raise the ValueError exception.
- D . The code will print Hello, World! to the console.
- E . The code will raise the AttributeError exception.
A
Explanation:
Topics: print() SyntaxError
Try it yourself:
# print(Hello, World!)
# SyntaxError: invalid syntax
The exclamation mark makes it a syntax error.
A function definition starts with the keyword:
- A . def
- B . function
- C . fun
A
Explanation:
Topic: def
Try it yourself:
def my_first_function():
print(‘Hello’)
my_first_function() # Hello
https://www.w3schools.com/python/python_functions.asp
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]
- A . can be executed if and only if the tuple contains at least two elements
- B . is illegal
- C . may be illegal if the tuple contains strings
- D . is fully correct
B
Explanation:
Topics: dictionary
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.
What is the expected output of the following code?
def func(x):
return 1 if x % 2 != 0 else 2
print(func(func(1)))
- A . The code is erroneous.
- B . None
- C . 2
- D . 1
D
Explanation:
Topics: def conditional expression (if else) modulus operator
not equal to operator
Try it yourself:
def func(x):
return 1 if x % 2 != 0 else 2
print(func(func(1))) # 1
print(1 % 2) # 1
print(1 % 2 != 0) # True
This is a conditional expression.
1 % 2 is 1 and therefore not equal to 0
The condition is True and the inner func() function call returns 1 That 1 is passed to the outer function which will also return 1
Take a look at the snippet, and choose the true statements: (Select two answers)
nums = [1, 2, 3]
vals = nums
del vals[1:2]
- A . nums is longer than vals
- B . nums and vals refer to the same list
- C . vals is longer than nums
- D . nums and vals are of the same length
B,D
Explanation:
Topics: list referencing list slicing del
Try it yourself:
nums = [1, 2, 3]
vals = nums
del vals[1:2]
print(nums) # [1, 3]
print(vals) # [1, 3]
A list is a mutable data type.
Assigning a mutable data type creates a reference to the same object.
vals and nums will point to the same object in the memory
and when you change one you automatically change the other, too.