Search Header Logo

Quiz – Python Programming

Authored by Tia Magalesh

Information Technology (IT)

University

Quiz – Python Programming
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

Which of the following is NOT a fundamental block of an algorithm?

Statements

Control flow

Pointers

Functions

Answer explanation

Pointers are not a fundamental block of an algorithm. The core components include statements, control flow, and functions, which define the structure and logic of an algorithm, while pointers are a programming concept used for memory management.

2.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

Which notation is commonly used for representing algorithms?

Flowchart

Pseudo code

Natural language

Binary code

Answer explanation

Pseudo code is a high-level description of an algorithm that uses structured language to outline its logic, making it easier to understand and implement. It is commonly used for representing algorithms compared to other options.

3.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

In recursion, a function calls:

Another function

The main function

Itself

Operating system

Answer explanation

In recursion, a function calls itself to solve smaller instances of the same problem. This self-referential behavior is what defines recursion, making 'itself' the correct answer.

4.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

Which of the following is an immutable data type in Python?

List

Tuple

Dictionary

Set

Answer explanation

In Python, a tuple is an immutable data type, meaning its elements cannot be changed after creation. In contrast, lists, dictionaries, and sets are mutable, allowing modifications to their contents.

5.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

What is the output of print(5//2)?

2.5

3

2

Error

Answer explanation

The expression 5//2 performs floor division, which divides 5 by 2 and rounds down to the nearest whole number. Thus, the output is 2, making '2' the correct answer.

6.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

Which function is used to find the absolute value of a number?

abs()

fabs()

modulus()

round()

Answer explanation

The function abs() is used to find the absolute value of a number, returning its non-negative value. The other options do not serve this purpose: fabs() is for floating-point, modulus() finds remainders, and round() rounds numbers.

7.

MULTIPLE CHOICE QUESTION

45 sec • 2 pts

Which loop executes at least once regardless of condition?

while

for

do-while (in Python)

None of these

Answer explanation

The correct answer is 'None of these' because in Python, the 'do-while' loop does not exist. The 'while' and 'for' loops may not execute at all if their conditions are false, while 'do-while' guarantees at least one execution in other languages.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?