wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PYTHON PROGRAMMING

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.

Who developed Python Programming Language?

a)

a) Wick van Rossum

b)

b) Rasmus Lerdorf

c)

c) Guido van Rossum

d)

d) Niene Stom

2.

which type of Programming does Python support?

.

a)

a) object-oriented programming

b)

b) structured programming

c)

c) functional programming

d)

d) all of the mentioned

3.

Is Python case sensitive when dealing with identifiers?

a)

a) no

b)

b) yes

c)

c) machine dependent

d)

d) none of the mentioned

4.

Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p

a)

a) .python

b)

b) .pl

c)

c) .py

d)

d) .p

5.

Is Python code compiled or interpreted?


a)

a) Python code is both compiled and interpreted

b)

b) Python code is neither compiled nor interpreted

c)

c) Python code is only compiled

d)

d) Python code is only interpreted

6.

Which of the following is used to define a block of code in Python language?


a)

a) Indentation

b)

b) Key

c)

c) Brackets

d)

d) All of the mentioned

7.

Which keyword is used for function in Python language?

a)

a) Function

b)

b) def

c)

c) Fun

d)

d) Define

8.

Python supports the creation of anonymous functions at runtime, using a construct called __________

a)

a) pi

b)

b) anonymous

c)

c) lambda

d)

d) none of the mentioned

9.

What is the order of precedence in python?

a)

a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

b)

b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction

c)

c) Parentheses, Exponential, Multiplication, Addition, Division, Subtraction

d)

d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

10.

What will be the output of the following Python function?

len(["hello",2, 4, 6])

a)

a) Error

b)

b) 6

c)

c) 4

d)

d) 3

11.

Which of the following is a Python tuple?


a)

a) {1, 2, 3}

b)

b) {}

c)

c) [1, 2, 3]

d)

d) (1, 2, 3)

12.

What will be the output of the following Python code?

>>> str1 = 'hello'

>>> str2 = ','

>>> str3 = 'world'

>>> str1[-1:]

a)

a)0olleh


b)

b) hello

c)

c) h

d)

d) o

13.

What will be the output of the following Python code?

>>>str1="helloworld"

>>>str1[::-1]



a)

a) dlrowolleh

b)

b) hello

c)

c) world

d)

d) helloworld

14.

What will be the output of the following Python code snippet?

print('abc'.islower())

a)

a) True

b)

b) False

c)

c) None

d)


d) Error

15.

What is the method inside the class in python language?

a)
  1. a)Object

b)
  1. b)Function

c)
  1. c)Attribute

d)

d) Argument

16.

Python is a:

a)

a)Low-level language

b)

b)High-level language

c)

c)Middle-level language

d)

d)Machine-level language

17.

What will be the output of the following Python code?

x = ['ab', 'cd']

for i in x:

    i.upper()

print(x)

a)

a) [‘ab’, ‘cd’]

b)

b) [‘AB’, ‘CD’]

c)

c) [None, None]

d)

d) none of the mentioned

18.

What will be the output of the following Python code?

i = 1

while True:

    if i%3 == 0:

        break

    print(i)

 

    i + = 1

a)

a) 1 2

b)

b) 1 2 3

c)

c) error

d)

d) none of the mentioned

19.

Which one of these is floor division?

a)

a) /

b)

b) //

c)

c) %

d)

d) None of the mentioned

20.

Which of the following data structures is returned by the functions globals() and locals()?


a)

a) list

b)

b) set

c)

c) dictionary

d)

d) tuple

21.

What will be the output of the following Python code?

x=1

def cg():

        global x

        x=x+1  

cg()

x



a)

a) 2

b)

b) 1

c)

c) 0

d)

d) Error

22.

What arithmetic operators cannot be used with strings in Python?

a)

a) *

b)

b) –

c)

c) +

d)

d) All of the mentioned

23.

Which of these in not a core data type?


a)

a) Lists

b)

b) Dictionary

c)

c) Tuples

d)

d) Class

24.

Which of the following is not the correct syntax for creating a set?


a)

a) set([[1,2],[3,4]])

b)

b) set([1,2,2,3,4])

c)

c) set((1,2,3,4))

d)

d) {1,2,3,4}

25.

What does the `range(3)` function return?

a)

a) [0, 1, 2]

b)

b) [1, 2, 3]

c)

c) [0, 1, 2, 3]

d)

d) [3, 2, 1]

26.

What is the correct way to import the `math` module in Python?

a)

a) import math

b)

b) use math

c)

c) from math import *

d)

d) import module math

27.

What does the `isalpha()` method do in Python strings?

a)

A) Checks if all characters in the string are alphabetic

b)

B) Checks if all characters in the string are digits

c)

C) Checks if the string is empty

d)

D) Converts the string to lowercase

28.

 What is the output of the following code?

```python
x = 3
y = 2
print(x / y)
```

a)

A) 6

b)

B) 1.5

c)

C) 0.6666666666666666

d)

D) Error

29.

Which of the following data types is mutable in Python?

a)

a) int

b)

b) float

c)

c) tuple

d)

d) list

30.

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

a)
  1. a)val()

b)
  1. b) print()

c)
  1. c)printf()

d)
  1. d) None of these