Free Python Institute PCEP-30-02 Exam Actual Questions

The questions for PCEP-30-02 were last updated On May 2, 2024

Question No. 1

A set of rules which defines the ways in which words can be coupled in sentences is called:

Show Answer Hide Answer
Correct Answer: B

Syntax is the branch of linguistics that studies the structure and rules of sentences in natural languages. Lexis is the vocabulary of a language. Semantics is the study of meaning in language. A dictionary is a collection of words and their definitions, synonyms, pronunciations, etc.


Question No. 2

Which of the following expressions evaluate to a non-zero result? (Select two answers.)

Show Answer Hide Answer
Correct Answer: A, B

In Python, the ** operator is used for exponentiation, the / operator is used for floating-point division, and the // operator is used for integer division. The order of operations is parentheses, exponentiation, multiplication/division, and addition/subtraction. Therefore, the expressions can be evaluated as follows:

A) 2 ** 3 / A - 2 = 8 / A - 2 (assuming A is a variable that is not zero or undefined) B. 4 / 2 * * 3 - 2 = 4 / 8 - 2 = 0.5 - 2 = -1.5 C. 1 * * 3 / 4 - 1 = 1 / 4 - 1 = 0.25 - 1 = -0.75 D. 1 * 4 // 2 ** 3 = 4 // 8 = 0

Only expressions A and B evaluate to non-zero results.


Question No. 3

Python Is an example of which programming language category?

Show Answer Hide Answer
Correct Answer: A

Python is an interpreted programming language, which means that the source code is translated into executable code by an interpreter at runtime, rather than by a compiler beforehand. Interpreted languages are more flexible and portable than compiled languages, but they are also slower and less efficient. Assembly and machine languages are low-level languages that are directly executed by the hardware, while compiled languages are high-level languages that are translated into machine code by a compiler before execution.


Question No. 4

How many hashes (+) does the code output to the screen?

Show Answer Hide Answer
Correct Answer: C

The code snippet that you have sent is a loop that checks if a variable ''floor'' is less than or equal to 0 and prints a string accordingly. The code is as follows:

floor = 5 while floor > 0: print(''+'') floor = floor - 1

The code starts with assigning the value 5 to the variable ''floor''. Then, it enters a while loop that repeats as long as the condition ''floor > 0'' is true. Inside the loop, the code prints a ''+'' symbol to the screen, and then subtracts 1 from the value of ''floor''. The loop ends when ''floor'' becomes 0 or negative, and the code exits.

The code outputs five ''+'' symbols to the screen, one for each iteration of the loop. Therefore, the correct answer is C. five.


Question No. 5

What happens when the user runs the following code?

Show Answer Hide Answer
Correct Answer: B

The code snippet that you have sent is calculating the value of a variable ''total'' based on the values in the range of 0 to 3. The code is as follows:

total = 0 for i in range(0, 3): if i % 2 == 0: total = total + 1 else: total = total + 2 print(total)

The code starts with assigning the value 0 to the variable ''total''. Then, it enters a for loop that iterates over the values 0, 1, and 2 (the range function excludes the upper bound). Inside the loop, the code checks if the current value of ''i'' is even or odd using the modulo operator (%). If ''i'' is even, the code adds 1 to the value of ''total''. If ''i'' is odd, the code adds 2 to the value of ''total''. The loop ends when ''i'' reaches 3, and the code prints the final value of ''total'' to the screen.

The code outputs 2 to the screen, because the value of ''total'' changes as follows:

When i = 0, total = 0 + 1 = 1

When i = 1, total = 1 + 2 = 3

When i = 2, total = 3 + 1 = 4

When i = 3, the loop ends and total = 4 is printed

Therefore, the correct answer is B. The code outputs 2.