Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basics of Programming

Total questions: 25

Worksheet time: 14mins

Name
Class
Date
1.

What is the output of the following code?

print(type(3))

a)

<class 'int'>

b)


<type 'int'>

c)


int

d)


D) <int>

2.

How do you insert comments in Python code?

a)

# This is a comment

b)

// This is a comment

c)

<!-- This is a comment -->

d)

/* This is a comment */

3.

Which of the following is a valid variable name in Python?

a)

2var

b)

var_1

c)

@var

d)

None

4.

What will the following code output?

print(5 // 2)

a)

2.5

b)

3

c)

2

d)

2.0

5.

What is the output of the following code?

print(bool(""))

a)

True

b)

False

c)

None

d)

Error

6.

What does the following code return?

list1 = [1, 2, 3, 4]

print(list1[-2])

a)

2

b)

3

c)

4

d)

error

7.

Which keyword is used to define a class in Python?

a)

class

b)

def

c)

define

d)

struct

8.

What does the following code return?

list1 = [1, 2, 3, 4]

print(list1[-2])

a)

2

b)

3

c)

4

d)

error

9.

What is the output of the following code?

x = 10

y = 20

x, y = y, x

print(x, y)

a)

10, 10

b)

20,20

c)

10,20

d)

20,10

10.

Which of the following is a Python immutable data type?

a)

List

b)

Set

c)

Dictionary

d)

Tuple

11.

Identify the below expressions which would result in False?

a) False and True b) 1==1 or 2==1

c) 1==1 and 2!=1 d) True and 1==1 e) False or 1>2

a)

c, d

b)

a, e

c)

b, c, d

d)

a, c

12.

what is the output of the below code snippet?

num1=10

num2=7//2

num2*=num1

print(num2)

a)

10

b)

35.0

c)

30

d)

30.0

13.

What is the output of the below code?

num_list = [10.5,30.5,-1.20,10.10]

num_list.insert(-3, -10.5)

num_list.pop(0)

print(num_list[0])

a)

30.5

b)

-10.5

c)

10.1

d)

-1.2

14.

print(~~~~~5)

a)

5

b)

-6

c)

10

d)

-10

15.

Python can be worked on with:

a)

Phones

b)

PCs

c)

Tablets

d)

Laptops

e)

Nintendo Wii

16.

Is Python case sensitive?

a)

Yes

b)

No

c)

Maybe

d)

Depends up on the version of python

17.

Which of the following is the correct extension of the Python file?

a)

.python

b)

.pl

c)

.py

d)

.p

18.

Is Python code compiled or interpreted?

a)

Python code is both compiled and interpreted

b)

Python code is neither compiled nor interpreted

c)

Python code is only compiled

d)

Python code is only interpreted

19.

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

a)

//

b)

#

c)

!

d)

/*

20.

Which of the following functions is a built-in function in python?

a)

fact()

b)

print()

c)

seed()

d)

squareroot()

21.

Which code is correct?

a)

ptinf("Hello World")

b)

print("Helloworld")

c)

printf "hello world"

d)

print (hello world)

22.

Which symbol is used for product calculations?

a)

x

b)

X

c)

*

d)

**

23.

Which one is integer datatype?

a)

w=1

b)

x=10.00

c)

y=010010123459714523697

d)

z=xa

24.

Select the string datatypes.

a)

+91547963

b)

B+ve

c)

1243

d)

5679 222^2  

25.

Which of the following will print the numbers 5,7,9,11,13 in a column

a)

for counter in range(13):

print(counter)

b)

for counter in range(5,13,2):

print(counter)

c)

for counter in range(5,13):

print(counter)

d)

for counter in range(5,14,2):

print(counter)