wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Basic Python

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

In Python, print () by default adds which of the following as an end line argument?

a)

\t

b)

\n

c)

\s

d)

\r

2.

Which of the following is not true about variable names?

a)

The length of the variable name is fixed

b)

Can contain upper case or lowercase letters and digits 0-9

c)

Variable names cannot begin with a digit

d)

Variable names are case sensitive

3.

What does IDE stand for?

a)

Internet Data Evaluation

b)

Integrated Drive Electronics

c)

Integrated Development Enterprises

d)

Integrated Development Environment

4.

In Spyder, the command to clear the console is

a)

%reset

b)

%clear

c)

%del

d)

%delete

5.

Which of the following code cannot be used to initialize multiple variables with a common value?

a)

a, b, c = 55

b)

a, b, c = 55, 55, 55

c)

a = b = c = 55

d)

a = 55; b = a; c = b

6.

What will be the output after executing the given codes?

a)

6

b)

42

c)

3

d)

52

e)

None

7.

Which of the following is true with respect to the below codes?


a = 4**3

b = pow(4,3)

print(a,b)

a)

a = b

b)

a ≠ b

c)

a < b

d)

a > b

8.

What will be the output after executing the given codes?

a)

Syntax error

b)

10

c)

value error

d)

20

9.

Which of the following conversion results in an error?

a)

int('10.8')

b)

float(10)

c)

int(10)

d)

float(10.8)

10.

For which type of error does the interpreter runs the program and does not report an error?

a)

Semantic error

b)

Syntax error

c)

Runtime error

d)

Key error

11.

What will be the output after executing the following codes?

x=27

y=4

print(x//y)

a)

SyntaxError

b)

6.75

c)

3

d)

6

12.

Identify which of the following is not a valid variable name?

a)

X005 =10

b)

A.2 = 10

c)

N_s = 10

d)

r10 = 10

13.

What does the following statements do?

import sys

print(sys.version)

a)

Displays the current Python version

b)

Displays the operating system version

c)

Displays the location of the Python interpreter

d)

All of the above

e)

None of the above

14.

How many operands are there in the following arithmetic expression?

6 * 35 + 8 – (25 / 5)

a)

4

b)

3

c)

5

d)

8

15.

Which is not a valid assignment operator?

a)

**=

b)

+=

c)

//=

d)

%%=

16.

Which of the following command is used to print the output 01-Jan-2020 ?

a)

print('01','Jan', sep=' ', end='-2020')

b)

print('01','Jan', sep='-', end='-2020')

c)

print('01','Jan', sep='-', end='2020')

d)

print('01','Jan','2020', sep='-', end='-2020\n')

17.

What is the correct file extension for Python files?

a)

.pyt

b)

.pyth

c)

.pt

d)

.py

18.

How do you start writing an if statement in Python?

a)

if (x>y)

b)

if (x>y):

c)

if (x,y)

d)

if (x>y) then:

19.

How do you insert COMMENTS in Python code?

a)

/*This is a comment*/

b)

#This is a comment

c)

//This is a comment

d)

Any of the Above

20.

What is a correct syntax to return the first character in a string?

a)

x = "Hello"[0]

b)

x = "Hello".sub(0, 1)

c)

x = sub("Hello", 0, 1)

d)

x = first("Hello")