top of page

Python Practice Set January 2023

Updated: Dec 31, 2022

1.


The output of the following code.

string=”my name is x”

for i in string:

print(i,end=”,”)

A. m,y,,n,a,m,e,,i,s,x,

B. m,y,,n,a,m,e,,i,s,x

C. my,name,is,x

D. None

Answer: (A)

2. What arithmetic cannot be used with strings?

A. +

B. *

C.

D. All of the mentioned

Answer: (C)

3. The output of the following code.

string=”my name is x”

for i in string.split():

print(i,end=”, ”)

A. m,y,,n,a,m,e,,i,s,,x,

B. m,y,,n,a,m,e,,I,s,,x

C. my,name,is,x,

D. Error

Answer: (C)

4. The output of the following code.

a=[0,1,2,3]

for a[-1] in a:

print(a[-1])

A. 0 1 2 3

B. 0 1 2 2

C. 3 3 3 3

D. error

Answer: (B)

5. The output of the following code.

a=[0,1,2,3]

for a [0] in a:

print(a[0])

A. 0 1 2 3

B. 0 1 2 2

C. 0 2 3 4

D.Error

Answer: (A)

6. The output of the following code.

a=[0,1,2,3]

i= -2

for i in not in a:

print(i)

i+=1

A. -2 -1

B. 0

C. Error

D.None of the mentioned

Answer: (C)

7. The output of the following code.

>>>”b”+”cde”

A. a

B. cde

C. bcd

D.Bcde

Answer: (D)

8. The output of the following code.

>>>”abcde”[3 :]

A. ab

B. de

C. cde

D.None

Answer: (B)

9. The output of the following code.

>>>print(‘new’ ‘line’)

A. error

B. output equialent to print ‘newline’

C. newline

D.new line

Answer: (D)

10. The output of the following code.

>>>max(“what are you”)

A. u

B. t

C. m

D.K

Answer: (A)

11. Which of the following statement prints helloexample test.txt?

A. print(“helloexample est.txt”)

B. print(“helloexample test.txt”)

C. print(“hello”example”test.txt”)

D.print(“hello”example “est.txt”)

Answer: (B)

12. The output of the following code.

print(“xyyzxyzxzxyy”.count(‘yy’))

A. 3

B. 0

C. 2

D.None

Answer: (C)

13. The output of the following code.

>>>str1=”helloworld”

>>>str1[: : -1]

A. dlrowolleh

B. Hello

C. world

D.Helloworld

Answer: (A)



14. what is the output of the below program in python:

print(0.2+0.4==0.6)

A. True

B. False

C. Error

D.Depends on machine

Answer: (B)

15. Which is not a feature of python language.

A. interpreted language

B. portable

C. high level language

D.case insensitive

Answer: (D)

16. Python is a …………object-oriented programming language.

A. Special purpose

B. General purpose

C. Medium level programming language

D.All of the mentioned above

Answer: (D)

17. Developer of python programming?

A. Denis Ritchie

B. Y.C Khenderakar

C. Tim Berner Lee

D.Guido van Rossum

Answer: (D)

18. Which are application areas of python programming?

A. Web development

B. Game development

C. Artificial intelligence and machine learning

D. All of the above

Answer: (D)

19. What is numeric types of data types?

A. int

B. Float

C. Complex

D.All of the above

Answer: (D)

20. What is the output for below code?

a = 2

b = 3

print(a,b)

a,b=b,a

print(a,b)

A. 23 23

B. 23 32

C. 32 32

D.None of above

Answer: (B)

21. List tuple dictionary are which types of datatypes?

A. Binary types