wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Worksheet

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

What is the first phase in the Python project cycle?

a)

Design

b)

Development

c)

Requirement Analysis

d)

Testing

2.

What activity is commonly done in both the testing and maintenance phases?

a)

Writing user stories

b)

Fixing bugs

c)

Creating diagrams

d)

Writing documentation

3.

Which of the following best defines an algorithm?

a)

A diagram showing steps

b)

A step-by-step procedure for solving a problem

c)

A computer program

d)

A software model

4.

What is a flowchart used for?

a)

Drawing architectural models

b)

Writing code

c)

Visually representing algorithms

d)

Designing databases

5.

In a flowchart, which symbol is used to represent a decision?

a)

Rectangle

b)

Parallelogram

c)

Oval

d)

Diamond

6.

Who developed Python?

a)

Dennis Ritchie

b)

Guido van Rossum

c)

Bjarne Stroustrup

d)

James Gosling

7.

Which of the following is used to output data in Python?

a)

echo()

b)

write()

c)

print()

d)

show()

8.

What is the correct way to create a variable in Python?

a)

var x = 10

b)

int x = 10

c)

x := 10

d)

x = 10

9.

What data type is the result of: type("123")?

a)

int

b)

str

c)

float

d)

bool

10.

Which of the following is NOT a Python data type?

a)

list

b)

tuple

c)

array

d)

dictionary

11.

Python is:

a)

Compiled

b)

Interpreted

c)

Both

d)

None

12.

Which of these is not a core data type?

a)

List

b)

Dictionary

c)

Tuple

d)

Class

13.

What is the output of this code? x = None print(type(x))

a)

Error

b)

String

c)

Bool

d)

NoneType

14.

Which of the following is a mutable data type?

a)

list

b)

tuple

c)

str

d)

int

15.

What will be the result of 3 + 2 * 2?

a)

10

b)

7

c)

9

d)

8

16.

What is the result of bool(0) in Python?

a)

True

b)

False

c)

0

d)

Error

17.

What type of error is raised by the following code? x = 10 print(x / 0)

a)

NameError

b)

TypeError

c)

ValueError

d)

ZeroDivisionError

18.

Which of the following is a valid Python variable name?

a)

1variable

b)

@name

c)

_value

d)

class

19.

What will this code output? a = [1, 2, 3] print(a[3])

a)

3

b)

IndexError

c)

None

d)

4

20.

Which of the following is NOT a keyword in Python?

a)

None

b)

pass

c)

eval

d)

if

21.

Which keyword is used to exit a loop early?

a)

continue

b)

exit

c)

break

d)

stop

22.

What does range(5, 1, -1) generate?

a)

5 4 3 2

b)

5 4 3 2 1

c)

5 3 1

d)

5 1

23.

Which of the following is String literal?

a)

“ABC”

b)

“123”

c)

Both of the above

d)

None of the above

24.

What will be the result of the following command:>>>'I love python'.capitalize()

a)

'I Love Python'

b)

'I love python'

c)

'I LOVE PYTHON'

d)

None of the above

25.

What will be the output of the following command: >>>string= "A quick fox jump over a lazy fox" >>>string.find("fox",9,34)

a)

29

b)

28

c)

8

d)

7

26.

Raman is using string.isspace() in his command, Help him to choose the correct option.

a)

returns True

b)

returns False

c)

Error

d)

None of the above

27.

Find the length of the following string using len( ) : >>>str= “World in Shock.”

a)

14

b)

15

c)

16

d)

17

28.

What will be the output of the following Code: >>>'India is my Country. I love my Country India'.replace("Country", "India")

a)

India is my Country. I love my Country India

b)

Country is my Country. I love my Country Country

c)

'India is my India. I love my India India'

d)

ERROR

29.

Write the correct code for the following output:- Output: 'W OO R LL D'

a)

>>>str="$" >>>join("WORLD",'$')

b)

>>> "$" = str >>> join("WORLD",'$')

c)

>>>str="$" >>>str.join("WORLD")

d)

>>>str="$" >>> join("WORLD").str

30.

The data type of x in the below code is: txt = "I could eat bananas all day" x = txt.partition("bananas")

a)

string

b)

List

c)

Tuple

d)

Dictionary

31.

The number of element return from the partition function is : >>>"I love to study python".partition("study")

a)

1

b)

3

c)

4

d)

5

32.

Which of the following methods can be used to check if a string ends with a particular suffix.

a)

end()

b)

endswith()

c)

finish()

d)

startswith()

33.

Which operator is used for string concatenation in Python?

a)

*

b)

+

c)

&

d)

%

34.

What will be the result of : "abc123".isalnum()

a)

True

b)

False

c)

Error

d)

None

35.

What does the following return? str1 = "hello" str2 = "HELLO" str1 == str2

a)

True

b)

False

c)

Error

d)

None

36.

What is the output of the following? s = "hello world" print(s.title())

a)

Hello World

b)

Hello world

c)

HELLO WORLD

d)

hello World

37.

What is the output of: print("apple,banana,grape".split(","))

a)

['apple banana grape']

b)

['apple', 'banana', 'grape']

c)

('apple', 'banana', 'grape')

d)

Error

38.

Which of the following list methods is used to delete element from the list?

a)

del( )

b)

delete( )

c)

pop( )

d)

All of these

39.

Suppose list1 is [1, 3, 2]. What is list1 * 2?

a)

[2, 6, 4]

b)

[1, 3, 2, 1, 3, 2]

c)

[1, 3, 1, 3, 2]

d)

[1, 2, 3, 2, 1]

40.

Given the list L=[-1,4,6,-5], write the output of print(L[1:-3])

a)

a)[4,6,-5]

b)

b[ ]

c)

c[6,-5]

d)

d)error