wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basics of Python Programming

Total questions: 44

Worksheet time: 25mins

Name
Class
Date
1.

Scholar No.

4 lines
2.

Name

4 lines
3.

Contact

4 lines
4.

College

4 lines
5.

What is the data type of x after the following statement?

x = ['Today', 'Tomorrow', 'Yesterday']

a)

List

b)

Dictionary

c)

Tuple

d)

String

6.

Output displayed by the print function will add this invisible character at the end of the line by default.

a)

\t

b)

\n

c)

\s

d)

\r

7.

Python files are saved with the extension as?

a)

.python

b)

.pe

c)

.py

d)

.pi

8.

What will be the output after the following statements?

x = True

y = False

print(x or y)

a)

True

b)

False

c)

Not defined

d)

xy

9.

What will be the output after the following statements?

x = 3

y = 7

print(x==y)

a)

y = 7 and x = 3

b)

True

c)

x = 3 and y = 3

d)

False

10.

What will be the output after the following statements?

x = ['Today', 'Tomorrow', 'Yesterday']

y = x[1]

print(y)

a)

x1

b)

Today

c)

Tomorrow

d)

Yesterday

11.

IDLE stands for ... ?

a)

Indigenous Development Lab

b)

Integrated Development Environment

c)

Integrated Developers Local Environment

d)

Integrated Development and Learning Environment

12.

What will be the data type of x after the following statement if input entered is 18 ?

x = input("Enter a number: ")

a)

Float

b)

String

c)

List

d)

Integer

13.

What will be the output after the following statements?

x = 3

y = 2

x += y

print(x)

a)

3

b)

2

c)

5

d)

1

14.

What will be the output after the following statements?

x = [15, 45, 85, 95]

print(x[3]-x[1])

a)

30

b)

40

c)

50

d)

10

15.

Which of the following is used to initialize multiple variables with a common value?

a)

x = y: y = 33

b)

x = y = z = 33

c)

x = z; y = z; x = 33;

d)

x & y & z = 33

16.

What will be the output after the following statements?

x = 46

y = 98

z = y if (y % 2 == 0) else x

print(z)

a)

True

b)

False

c)

46

d)

98

17.

For which type of error does the interpreter halts and reports the error but does not execute the program?

a)

Semantic error

b)

Syntax error

c)

Runtime error

d)

All type of errors

18.

What will be the output after the following statements?

x = [5, 4, 3, 2]

x.insert(1,0)

print(x)

a)

[5, 1, 3, 2, 0]

b)

[5, 0, 4, 3, 2]

c)

[0, 5, 4, 3, 2]

d)

[1, 5, 4, 3, 2]

19.

What will be the output after the following statements?

x = [5, 4, 3, 2]

x.remove(2)

print(x)

a)

[5, 3, 2]

b)

[5, 4, 3]

c)

[5, 4, 2]

d)

[3, 2]

20.

What will be the output after the following statements?

x = ['Sunday', 'Monday', 'Tuesday']

y = x[1] + x[2]

print(y)

a)

MondayTuesday

b)

SundayMonday

c)

SunMonday

d)

Monday Tuesday

21.

What will be the value of x, y and z after the following statement?

x, y, z = 3, 4, 5

a)

All three will have the value of 3

b)

All three will have the value of 345

c)

x will have the value of 3, y will have the value 4 and z will have the value of 5

d)

x and y will have arbitrary values, while z will have the value of 345

22.

What will be the output after the following statements?

x = [25, 35, 45]

y = x[0]

print(y)

a)

x0

b)

25

c)

35

d)

45

23.

What will be the output after the following statements?

x = [[0.0, 1.0, 2.0], [4.0, 5.0, 6.0]]

print(x[1][2])

a)

0.0

b)

1.0

c)

5.0

d)

6.0

24.

What will be the output after the following statements?

x = '24' + '16'

print(x)

a)

40

b)

2416

c)

21

d)

46

25.

What will be the output after the following statements?

x = [[0.0, 1.0, 2.0], [4.0, 5.0, 6.0]]

y = x[0][1] + x[1][0]

print(y)

a)

1.0

b)

4.0

c)

5.0

d)

6.0

26.

What will be the output after the following statements?

x = 8

y = 2

print(x // y)

a)

4.0

b)

4

c)

16

d)

16.0

27.

What will be the output after the following statements?

x = [10, 20, 30]

y = x[1] + x[2]

print(y)

a)

20

b)

30

c)

40

d)

50

28.

For which type of error does the interpreter runs the program and does not report an error?

a)

Semantic error

b)

Syntax error

c)

Runtime error

d)

All type of errors

29.

What will be the output after the following statements?

x = [5, 4, 3, 2]

x.append(1)

print(x)

a)

[5, 4, 3, 2]

b)

5, 4, 3, 2

c)

5432

d)

[5, 4, 3, 2, 1]

30.

User input is read as...?

a)

Floating Decimal

b)

Text String

c)

Boolean Value

d)

Integer

31.

What will be the output after the following statements?

foo = 20>>3

foo <<= 1

foo |= 8

print(foo, type(foo))

a)

4 <class 'int'>

b)

12 <class 'int'>

c)

20 <class 'int'>

d)

None of These

32.

What will be the output after the following statements?

a = '24' + '35'

a /= 5

print(a, type(a))

a)

2435 <class 'int'>

b)

59 <class 'int'>

c)

11.8 <class 'float'>

d)

TypeError

33.

What will be in <put your code here 1, 2, 3> ?

a)

year%400 == 0 ; year%100 == 0 ; year%4 == 0

b)

year%400 == 0 ; year%4 == 0 ; year%100 == 0

c)

year%100 == 0 ; year%400 == 0 ; year%4 == 0

d)

None of These

34.

What will be in <put your code here> ?

a)

beg, ending

b)

beg, ending + 1

c)

0, ending + 1

d)

None of These

35.

Consider a variable job = "chemist". Which of the following expressions will retrieve the last character from the variable value?

a)

job[7]

b)

job[len(job) - 1]

c)

job[5:6]

d)

job[- 1]

e)

All of the above statements are true

36.

Which of the following expressions should be used to assign the variable get_num to get the final print statement output as value 75 from the below tuple?

nst_tup = ("System", (60, 75, 45), (15, 13, 12))

get_num = ..........

print(get_num)

a)

nst_tup[1][2]

b)

nst_tup[1:2][1]

c)

nst_tup[1][1]

d)

nst_tup[1:2](1)

e)

None of the above

37.

What would be the output for the following set of statements?

new_list = [13, 23, 18, 64, 51]

new_list[4] = True

print(new_list)

a)

[13, 23, 18, 64, 51, “True”]

b)

[13, 23, 18, 64, True]

c)

[13, 23, 18, 64, 51, True]

d)

Index Error

38.

What result does the final statement print?

scores = (12, 25, 32, 39, 44)

f_score, *bw_s, l_score = scores

print("Output is :", f_score,"and",bw_s,"and", l_score)

a)

Output is: 12, (25, 32, 39), 44

b)

Output is: 12 and (25, 32, 39) and 44

c)

Output is: 12 and 25 and 39

d)

ValueError: Too many values to unpack

e)

Output is: 12 and [25, 32, 39] and 44

39.

When the following set of instructions are executed, how many times does the vowel “e” appear in the result?

word = "occurence"

for itr in range(len(word)):

if itr%3 == 0:

print(word[itr])

a)

1

b)

“e” is not printed

c)

2

d)

4

e)

None of the above

40.

Consider a dictionary city created with the following keys and values.

city = {'Delhi':3, 'Bengaluru':5, 'Chennai':4, 'Kolkata':6, 'Mumbai':7}

What ways can be used to get the value 5?

a)

city['Bengaluru']

b)

city.get['Bengaluru']

c)

city.values()[1]

d)

list(city.values())[1]

e)

None of the above

41.

Count the number of elements in the below list.

list_tens = [["October", 24, ["2022"]]]

a)

2

b)

1

c)

3

d)

0

e)

None of the above

42.

From the following set of statements, what will be the value of variable y in the final print statement?

y = 1**2**3**2

print(y)

a)

8

b)

9

c)

1

d)

Error

e)

16

43.

What would be the output of the following statements?

log_exp = not not True and False or not False

print(log_exp)

a)

False

b)

True

c)

Not True

d)

None of the above

44.

Consider two answers to a question; answer1 and answer2. What is the output of the following set of statements?

answer1 = True

answer2 = False

print(answer1*answer2)

a)

True

b)

False

c)

0

d)

1