wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What will be the datatype of the var in the below code snippet?

a)

float and str

b)

number and str

c)

int and str

d)

number and char

2.

How is a code block indicated in Python?

a)

Bracket

b)

Indentation

c)

Key

d)

None of the above

3.

What will be the output of the following code snippet?

a)

[2,2,3]

b)

(2,2,3)

c)

(1,2,3)

d)

Error

4.

What will be the output of the following code snippet?

a)

int and float

b)

float and int

c)

float and float

d)

int and int

5.

What will be the output of the following code snippet?

a)

15

b)

0

c)

20

d)

None of these

6.

Which of the following concepts is not a part of Python?

a)

Pointers

b)

Loops

c)

Dynamic typing

d)

All of the above

7.

What will be the output of the following code snippet?

a)

['Sunday','Monday','Tuesday','Wednesday']

b)

['Monday','Tuesday','Wednesday']

c)

['Sunday','Monday','Wednesday']

d)

None of these

8.

Which of the following are valid string manipulation functions in Python?

a)

count()

b)

upper()

c)

strip()

d)

All of the above

9.

Which of the following modules need to be imported to handle date time computations in Python?

a)

datetime

b)

date

c)

time

d)

timedate

10.

In which language is Python written?

a)

C++

b)

Python

c)

C

d)

None of these

11.

Which type of Programming does Python support?

a)

object oriented programming

b)

structured programming

c)

functional programming

d)

All of the above

12.

Which of the following character is used to give single-line comments in Python?

a)

//

b)

#

c)

<!-- -->

d)

$

13.

Which one of the following is not a keyword in Python language?

a)

pass

b)

eval

c)

assert

d)

nonlocal

14.

Which of the following is a feature of Python DocString?

a)

In Python all functions should have a docstring

b)

It provides a convenient way of associating documentation with Python modules, functions, classes, and methods

c)

Docstrings can be accessed by the __doc__ attribute on objects

d)

All of the mentioned

15.

a = True

b = False

c = False

if a or b and c:

print ("GEEKSFORGEEKS")

else:

print ("geeksforgeeks")

What will be the output?

a)

GEEKSFORGEEKS

b)

geeksforgeeks

c)

GEEKSFORGEEKS

geeksforgeeks

d)

Run time error (Multiple operators in a single if statement)