wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Select the Data Type which is not present in Python Language

a)

Integer

b)

Boolean

c)

Number

d)

Float

e)

String

2.

What letter will be printed on the screen after running this code:

x = 'Python Programming'

l =x[-4:-1]

a)

Error

b)

ming

c)

Prog

d)

min

e)

ing

3.

The string data type is an immutable data type

a)

True

b)

False

4.

word = "amazing"


For the given string if we execute word[2:5] , what would the result be?

a)

amaz

b)

mazi

c)

azi

d)

azin

5.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

6.

What is the output of the following statement?


print(3 * "Hello")

a)

Error

b)

3Hello

c)

Hello3

d)

HelloHelloHellow

7.

What will the output be from the following code?

print("Hello world!\nHello world!")

a)

Hello world! Hello world!

b)

Hello world!

Hello world!

c)

SyntaxError

d)

Hello world!

8.

Python accepts single ('), double (") and triple (''' or """) quotes to denote strings. Which of the following is NOT acceptable Python syntax?

a)

print('Hello World')

b)

print("Hello World")

c)

print('Hello World")

d)

print(""'Hello World'"")

9.

Is the below statement valid in Python?


x,y,z = 10,20,30

a)

Valid

b)

Invalid

10.

x = input("How many days are in one year?")


print(x,type(x))


What is the output of the above command?

a)

3 <class 'int'>

b)

3 <class 'str'>

c)

3 <class 'float'>

d)

Error