PCEP Practice Exam 5

PCEP Practice Exam 5

10th Grade

30 Qs

quiz-placeholder

Similar activities

Honesty

Honesty

10th Grade

25 Qs

CL10 Quiz Day

CL10 Quiz Day

10th - 12th Grade

28 Qs

Fe y razón

Fe y razón

10th Grade

30 Qs

PCEP Practice Exam 5

PCEP Practice Exam 5

Assessment

Quiz

Religious Studies

10th Grade

Medium

Created by

Henry Vo

Used 16+ times

FREE Resource

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements is incorrect:

An indentation in Python language is mandatory

The '#' is used as single line comments and the """ """ (triple quote) is used as multi-line comments

We don't need to declare the type of a variable in Python program

All of these are correct.

Answer explanation

Python is indentation-strict language. We can use # for single line comments or triple quotes for multiple-line comments (usually called DocStrings). Python is a dynamically typed language so we don't need to declare the variable data type.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will the output be when the following code is executed?

"Robert, 123455667, Dar es salaam "

Robert 123455667 Dar es salaam

SyntaxError

Robert' 123455667 'Dar es salaam '

Answer explanation

Multiple variables can be assigned values as shown in the example above. Keep in mind that we must have the same number of variables and values, otherwise we will get one of the following errors depending on the situation: TypeError: cannot unpack non-iterable int object if the number of values on the right side is less than the number of variables on the left side. ValueError: too many values to unpack if the number of values on the right side is larger than the number of variables on the left side.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will be the output when the following code is executed?

\n:\n:\n

:

:

:

Three blank lines

error

Answer explanation

The end = "\n\n\n" will append three newline characters (\n) after printing out the text. Since there are no objects provided to the print() function to be printed, only the three empty lines will be printed. The sep is redundant in this code as there is no text to be printed.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will be the output when the following code is executed?

25

256

error

25.6

Answer explanation

The int function will round down to the previous whole number, in this case 25.

5.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

Which of the following statements is incorrect (select all that apply):

The bool("123") will return True

The bool("") will return True

The bool({}) will return False

The bool(-1) will return False

Answer explanation

The bool function when provided an empty string, empty object, or zero, will return False. In any other case, it will return True. bool("") evaluates to False as it is an empty string and the bool(-1) evaluates True as -1 is a non-zero value.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What would be the output of the following code:

1

2

4

25

Answer explanation

The exponentiation will take precedence over modulo, hence the above expression can be simplified to 2 % 25 . The remainder of the division of 25 by 2 is 2.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will be the output when the following code is executed?

False

True

SyntaxError

error

Answer explanation

The if condition will evaluate to False as since p is not less than 10, q is not greater than 20 and r is not greater than 30. Hence the else block will get executed. Note: In this example, all of the conditions in the if statement evaluate to False. However in another scenario, even if only one of them is False, the if block would not get executed.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?