
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
B. Boolean types
C. Sequence types
D.None of the above
Answer: (C)
22. Which keyword used in python language?
A. Finally
B. Lambda
C. While
D.All of above
Answer: (D)
23. Python Dictionary is used to store the data in.
A. Key value pair
B. Set value pair
C. Tuple value pair
D.None of the above
Answer: (A)
24. Which is invalid variable?
A. my_string_1
B. _
C. Foo
D.1st_string
Answer: (D)
25. What is the output of given code?
4+2**5//10
A. 77
B. 7
C. 3
D.0
Answer: (B)
26. The python language developed in which?
A. 1995
B. 1989
C. 1972
D.1981
Answer: (B)
27. Single line comment in python?
A. /
B. //
C. #
D.!
Answer: (C)
28. Conditional statements are also known as.
A. Decision-making
B. Array
C. List
D.Looping
Answer: (A)
29. Which is not used as Conditional statement in python?
A. switch
B. if…else
C. elif
D.For
Answer: (A)
30. which string represent the purpose for which the file is open?
A. “file name”
B. “file handle”
C. “file mode”
D.None of above
Answer: (C)
31. File handle is also know as.
A. File name
B. File variable
C. File object
D.none of above
Answer: (C)
32. which () finf the current position of file pointer with in file?
A. Seek()
B. Tell()
C. Read()
D.All of above
Answer: (B)
33. What is packing.
A. it is used for object serialization
B. It is used for object deserialization
C. All of the mentions
D.None of above
Answer: (A)
34. Eof standed for.
A. End of file
B. End of close
C. End of open
D.None of them
Answer: (A)
35. Input device.
A. Headphone
B. Gps
C. Microphone
D.All of above
Answer:(C)
36. To reped the list up to a spacify a number of iteam. Which operater required?
A. +
B. *
C. :
D.None
Answer:(C)
37. What type of data is?
a=[(1,1),(2,5),(3,9)]
A. array of tuple
B. tuples of list
C. List of tuple
D.invalid list
Answer:(C)
38. What will be print?
Import numpy as np
a = np. array([1,2,3,5,8])
b = np. array([0,3,4,2,1])
c = a+b
c = c*a
print(c[2])
A. 7
B. 12
C. 10
D. 21
Answer: D
39. import numpy as np.
a = np.array([[1,2,3],[0,1,4]])
print(a.size)
A. 1
B. 5
C. 6
D. 4
Answer: C
40. import numpy as np
a = np.array([1,2,3,5,8])
print(a.ndim)
A. 0
B. 1
C. 2
D. 3
Answer: B
41. Numpy stands for.
A. Numbering Python
B. Number in Python
C. Numerical Python
D. Number Python
Answer: C
42. numpy is used along with package like?
A. Node Js
B. Matplotlib
C. Scipy
D. Both(B)and(C)
Answer: D
43. the sets the size of the buffer used in ufuncs?
A. bufsize(size)
B.setsize(size)
C. set bufsize(size)
D. Size(size)
Answer: C
44. import numpy as np
dt=dt= np.dtype(‘i,4’)
print(dt)
A. int 32
B. int 64
C. int 128
D. int 16
45. if a dimension is given as _ in a reshaping operation, the other dimensions are Automate cally calculated.
A. Zero
B. One
C. Negative one
D. Infinite
Answer: (C)
46. Testing process first goal.
A. Testing
B. Analysis
C. Bug preventation
D. All of above
Answer: (C)
47. Sorting means.
A. Arranging the data
B. Processing the data
C. Calegrizing
D.None of above
Answer: (A)
48. Medium of comonunication.
A. Network
B. Compiler
C. Language
D.All of above
Answer: (C)
49. Bug means.
A. An insert in the program
B. Data input to the program
C. The error in the program
D.All of the above
Answer: (C)
50. Identifire maxium possible lenth.
A. 31 character
B. 63 character
C. 79 charater
D.None of the above
Answer: (C)
51. Which of the following is an invalid variable.
A. my_string_1
B. 5 st_string
C. Too
D.__
Answer: (B)
52. Which function do you use to read a string?
A. input(“enter a string”)
B. eval(input(“enter a string”))
C. enter(“enter a string”)
D.eval(enter(“enter a string”))
Answer: (A)
53. What will be the output of the following python code?
print(“abc DEF”.capitalize())
A. abc def
B. ABC DEF
C. Abc def
D. Abc Def
Answer: (C)