wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics till Logical Operators

Total questions: 35

Worksheet time: 11mins

Name
Class
Date
1.

Who developed the Python programming language?

a)

James Gosling

b)

Guido van Rossum

c)

Dennis Ritchie

d)

Bjarne Stroustrup

2.

In which year was Python first released?

a)

1995

b)

1989

c)

1991

d)

2000

3.

Why is the language named 'Python'?

a)

It is named after a type of snake.

b)

It was an acronym for "Program Your Tasks on Numbers."

c)

It is a randomly chosen name.

d)

Guido van Rossum was a fan of the television show "Monty Python's Flying Circus."

4.

What was the major feature introduced in Python 2.0?

a)

Object-oriented programming

b)

Garbage collection using reference counting

c)

List comprehensions

d)

Dynamic typing

5.

Which of the following statements is true about Python 3?

a)

It is backward-compatible with Python 2.

b)

It was released in 2008 to address the shortcomings of Python 2.

c)

Python 3.0 introduced the print statement.

d)

Python 3 removed support for object-oriented programming.

6.

Which of the following operators has lower precedence than the comparison operators (e.g., ==, <, >)?

a)

Logical OR (or)

b)

Addition (+)

c)

Bitwise AND (&)

d)

Exponentiation (**)

7.

What is the associativity of the assignment operator = in Python?

a)

Left-to-right

b)

Right-to-left

c)

Non-associative

d)

Undefined

8.

Which operator has the highest precedence in Python?

a)

Multiplication (*)

b)

Parentheses (())

c)

Logical AND (and)

d)

Exponentiation (**)

9.

What is the associativity of the exponentiation operator (**) in Python?

a)

Left-to-right

b)

Right-to-left

c)

Non-associative

d)

Both A and B

10.

Which of the following correctly describes the precedence order of these operators?

a)

*, +, ==, not

b)

not, ==, *, +

c)

*, +, not, ==

d)

+, *, not, ==

11.

Which of these is NOT a Python token?

a)

Keyword

b)

Identifier

c)

Literal

d)

Indentation

12.

Which of the following is a valid floating-point literal?

a)

1.0e-2

b)

0x1.2p3

c)

.5

d)

All of the above

13.

What will happen if you use a keyword as an identifier?

a)

ValueError

b)

SyntaxError

c)

RuntimeError

d)

LogicalError

14.

What is the type of the literal None in Python?

a)

String

b)

Boolean

c)

NoneType

d)

NullType

15.

What is the difference between keywords and identifiers?

a)

Keywords can only be used for variable names, whereas identifiers are reserved words.

b)

Keywords are predefined and reserved, while identifiers are user-defined names.

c)

Both keywords and identifiers can be used interchangeably.

d)

Identifiers are reserved words, whereas keywords are user-defined.

16.

Which of the following is NOT a valid Python keyword?

a)

pass

b)

yield

c)

define

d)

async

17.

Which of these are valid literals in Python?

a)

0b101

b)

"Hello"

c)

3j

d)

All of the above

18.

What will be the output of the following expression?

not (4 > 3 and 7 < 10) or (5 != 5 and 2 < 1)

a)

True

b)

False

c)

None

d)

SyntaxError

19.

What will be the output of the following expression?

not 0 or 1 and 2

a)

True

b)

2

c)

False

d)

0

20.

What will be the result of this expression?

not (6 and 0) or 3 and not 0

a)

True

b)

False

c)

3

d)

1

21.

Evaluate the following:

4 * 2 > 7 and 3 * 2 == 9 or 10 // 3 > 3

a)

True

b)

False

c)

None

d)

SyntaxError

22.

What will be the output of the following code?

print(input("Enter a number: ") + 5)

a)

Displays the entered number plus 5.

b)

Concatenates the entered value with 5.

c)

Error: Unsupported operand types for +.

d)

None of the above.

23.

What is the output of the following code?

print("Value is:", print("Nested print"))

a)

Value is: Nested print\n

b)

Value is: None Nested print\n

c)

Nested print\n

d)

Nested print\nValue is: None\n

24.

According to PEP 8, what is the maximum recommended line length for Python code?

a)

80 characters

b)

120 characters

c)

79 characters

d)

101 characters

25.

Which of the following statements about PEP 20 (The Zen of Python) is incorrect?

a)

It can be accessed by importing this in Python.

b)

It consists of 20 guiding principles for Python's design.

c)

The principle "Readability counts" is a part of PEP 20.

d)

The last principle is written as "There should be one-- and preferably only one --obvious way to do it."

26.

Which of the following Zen of Python principles is NOT explicitly stated in PEP 20?

a)

"Simple is better than complex."

b)

"Beautiful is better than ugly."

c)

"Readability counts."

d)

"Performance matters more than readability."

27.

What is the primary purpose of a flowchart?

a)

To write detailed code for a program

b)

To visually represent the logic of a process or algorithm

c)

To debug code more efficiently

d)

To measure the performance of an algorithm

28.

Which of the following best describes pseudocode?

a)

A high-level description of an algorithm in plain language

b)

A fully functional Python program

c)

A flowchart representation of a program

d)

A machine-readable code for compilers

29.

Which symbol is typically used in a flowchart to represent a decision?

a)

Oval

b)

Rectangle

c)

Diamond

d)

Arrow

30.

What is the output of the following pseudocode?

SET x = 5

SET y = 10

IF x + y > 15 THEN

PRINT "Sum is large"

ELSE

PRINT "Sum is small"

a)

Sum is large

b)

Sum is small

c)

Error in pseudocode

d)

No output

31.

Which of the following is NOT a characteristic of a good algorithm?

a)

Finiteness

b)

Ambiguity

c)

Effectiveness

d)

Definiteness

32.

What does PEP stand for in Python?

a)

Python Execution Protocol

b)

Python Enhancement Proposal

c)

Python Efficiency Practice

d)

Python Extended Principles

33.

What will the following code output?

x = 1.5

y = 2

z = (x + y) * (1 + 1j)

print(type(z))

a)

<class 'int'>

b)

<class 'float'>

c)

<class 'complex'>

d)

Error

34.

What will happen when the following code is executed?

x = int("12.34")

a)

12

b)

12.34

c)

Error: ValueError

d)

Error: TypeError

35.

What will happen when the following code is executed?

x = "hello"

y = 3

print(x * y + y)

a)

hellohellohello3

b)

hellohellohellohello

c)

Error: ValueError

d)

Error: TypeError