Search Header Logo

Python Programming Quiz

Authored by Shubham Mishra

Computers

University

Used 2+ times

Python Programming Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

17 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following statement: print(not(10/5//5 or 100 and 0))

100

True

0

False

Answer explanation

The expression evaluates as follows: 10/5//5 is 0, 100 and 0 is 0, so we have not(0 or 0) which simplifies to not(0). Since not(0) is True, the output is True.

2.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which of the following is/are valid identifier?

while

f_name

#code

_size

AD2023

Answer explanation

Valid identifiers must start with a letter or underscore and can contain letters, digits, and underscores. 'f_name', '_size', and 'AD2023' meet these criteria, while 'while' is a reserved keyword and '#code' contains an invalid character.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

(ii) Fill in the blank: _________ is a basic logic gate, whose output is 0 on same inputs.

NOT

AND

OR

XOR

Answer explanation

The XOR (exclusive OR) gate outputs 0 when both inputs are the same (either 0 or 1). In contrast, AND and OR gates output 1 for certain same inputs, making XOR the correct choice for this question.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

ii) Single line comments in python begin with ____ symbol.

&

$

%

#

Answer explanation

Single line comments in Python begin with the '#' symbol. This is the correct choice, as the other options (&, $, %) do not denote comments in Python.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

i) State TRUE/FALSE: Relational operators have less precedence over logical operators

TRUE

FALSE

Answer explanation

FALSE is correct because relational operators (like <, >) have higher precedence than logical operators (like &&, ||). This means relational operations are evaluated before logical operations in expressions.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

(ii) Which keyword(s) is/are used for looping in Python?

while

for

both a & b

if

Answer explanation

In Python, the keywords 'while' and 'for' are used for looping. 'while' creates a loop that continues as long as a condition is true, while 'for' iterates over a sequence. Therefore, the correct answer is 'both a & b'.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The correct operator precedence among Arithmetic (A), Bitwise (B), Logical (L), and Relational (R) is (higher rank appears first):

A B L R

B A R L

B A L R

A B R L

Answer explanation

The correct operator precedence is Bitwise (B) first, followed by Arithmetic (A), then Logical (L), and finally Relational (R). Thus, the order is B A L R.

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?

Discover more resources for Computers