Python Programming Quiz

Python Programming Quiz

University

17 Qs

quiz-placeholder

Similar activities

Python Functions and File Operations Quiz

Python Functions and File Operations Quiz

University

20 Qs

Round-1 Technical Aptitude

Round-1 Technical Aptitude

11th Grade - Professional Development

20 Qs

coding

coding

KG - Professional Development

15 Qs

Quiz1_7A

Quiz1_7A

2nd Grade - Professional Development

20 Qs

Success Criteria (Year 7 -8) Autumn Half-Term 1

Success Criteria (Year 7 -8) Autumn Half-Term 1

8th Grade - University

19 Qs

MIDTERM EXAM (CSPL)

MIDTERM EXAM (CSPL)

University

20 Qs

Activity Quiz

Activity Quiz

University

12 Qs

Python ir Colab

Python ir Colab

University

17 Qs

Python Programming Quiz

Python Programming Quiz

Assessment

Quiz

Computers

University

Medium

Created by

Shubham Mishra

Used 2+ times

FREE Resource

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.

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?