0% found this document useful (0 votes)
13 views

Python practice questions 1234

Uploaded by

Hina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Python practice questions 1234

Uploaded by

Hina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Python Practice Questions

1. Why Python is important for data science?

2. Python is interpreted or compiled?

3. What is the extension of Python source code?

4. What is .pyc file?

5. What is Jupyter Notebook?

6. What is intermediate code known as in Python?

7. How to check whether an object is an iterable or not?

8. Why is Python called interpreted language?

9. What are the two stages of type checking?

10. What is the difference between continue and pass statements in Python?

11. What happens when we restart the kernel?

12. What is a sequence type and no sequence type in Python?

13. List is hashable or unhashable?

14. What is a docstring in Python?

15. How to check Python version?

16. What is the difference between iterable and iterator in Python?

17. What is scope in Python?

18. What is the key difference between a list and a tuple?

19. What is slicing in Python?

20. Define a variable num and assign an int value to it. Check the memory consumed by num.

21. When we import a module. It is available in which namespace?

22. How to access a function which is a part of a module?

23. What is the difference between a function and a method?


24. What is PEP 8?

25. Define a list of squares of even numbers from 2 to 20 using list comprehension.

26. String is mutable or immutable?

27. What is pickling and unpickling in Python?

28. What is anonymous function in Python?

29. What is the difference between Series and Dataframe?

30. The following is a Series or a Dataframe?

Name
0 Amit
1 Sujata
2 Kalaipriya
3 Nitin
4 Ranjith
5 Arthi
6 Arvind
7 Gyan
8 Harshith
9 Neha

31. Why Python is called interpreted?

32. What is a generator in Python?

33. Tuple comprehension returns a tuple, generator?

34. What is shallow copy and deep copy?

35. Name any two compiled languages.

36. How do we access a method on an object?

37. What is a keyworded argument?

38. What are the negative indexes?

39. When do we get attribute error?

40. When do we get key error?


41. What is exceptional handling and why is it used?

42. Does Python support object-oriented programming?

43. Can we keep a class in a module?

44. Can we use append() on a string?

45. What is the difference between extend() and append() on a list?

46. Which of the following is not a sequence type?

i. List
ii. Tuple
iii. Set
iv. String

47. What is a binary search method?

48. Name any three iterator objects?

49. Dictionary is mutable or immutable?

50. Which function do we use to get the list of all the example datasets in Seaborn?

51. Check the version of Seaborn?

52. Which function do we use to plot a matplotlib plot on Seaborn defaults?

53. Which of the following supports the vectorize operations?

i. List
ii. NumPy array

54. Which of the following can not contain heterogenous elements?

i. List
ii. Array

55. Which of the following uses pointers to access an element?

i. List
ii. Array

56. What is .loc and .iloc in Pandas?

57. Which function gives statistical summary in Pandas?

58. Can we have heterogenous elements in a Series?

59. A data frame is like a 1D array structure?


60. Pandas has been developed over NumPy. True or False?

61. What is the other name of figure and axes approach in Matplotlib?

62. Define functional approach in Matplotlib.

63. What is the universal function to plot on x and y axis in Matplotlib?

64. Which function is used to create a regression plot in Seaborn?

65. Which function plots a multi panel figure in Seaborn?

66. What is univariate and bivariate analysis?

67. What is the magical command in Matplotlib?

68. What is the difference between count plot and bar plot?

69. Which function is used to display an image in Matplotlib?

70. What is the full form of NumPy?

71. What is the full form of SciPy?

72. Which function is used to load an example dataset in Seaborn?

73. Do we need to pass the extension while loading an example dataset in Seaborn?

74. Create a 2-D array of the shape 3*4 that has all the elements as 0.

75. Create an array of random integer values of the shape 4*4 and then convert into a 3D array of

the shape 2*4*2.

76. The following array is arr.

array([[[99, 83, 22, 85],


[86, 64, 30, 26],
[54, 98, 18, 92],
[63, 63, 38, 74]],

[[48, 57, 18, 88],


[84, 44, 13, 44],
[73, 65, 38, 45],
[89, 68, 44, 49]],

[[75, 77, 97, 44],


[88, 69, 50, 68],
[64, 59, 53, 45],
[34, 42, 92, 86]]])
Slice the following array from the above array

array([[18],
[13],
[38],
[44]])

77. Can we pass a list as a key to a dictionary?

78. A tuple can be passed as a key to a dictionary. True or False?

79. Create a dictionary using dict comprehension where keys are the even numbers from 2 to 10

and the values are the squares of the keys.

80. Write a program to find the index of an element from the following list using binary search
method.
[10, 20, 30, 40, 50, 60, 70, 80]

81. Write the syntax to slice a 3D array

82. There is a file abc.py that has the following code. If we execute it from the command prompt
what will be the output?

print(‘Hello’)
print(__name__)

83. If we import the above file abc.py in a Jupyter Notebook and then we execute the following
command. What will be the output?
print(abc. __name__)
84. What is a class in Python?

85. The variables are stored in which area in the memory in a .py file.

86. Check the Python version.

87. Print all the available keywords in Python.

88. print() returns the value it prints. True or False?

89. Print the list of all the available built-in names in Python.

90. Indentation defines the scope in Python. True or False?

91. Define a tuple of a single element without using ().

92. Bytes is mutable. True or False?


93. We can not store a dictionary inside a set. True or False?

94. A frozenset supports add().

95. How can we use a function that is available in built-in names?

96. How can we use a method that is defined inside a class?

97. Write a generator function to find the factorial of a number.

98. Print the character that is available at the Unicode value 189.

99. Write the short cut key to convert the mode of a cell from markdown to code.

100. Create a data frame that has only single column.

You might also like