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

Python_Questions

Uploaded by

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

Python_Questions

Uploaded by

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

I UNIT Questions

1. Explain why Python is a popular programming language and list at least three key
reasons for its popularity.
2. Name and describe the use of five essential Python libraries.
3. Provide a brief history of Python and its evolution over the years.
4. Discuss the main features of Python that make it unique compared to other
programming languages.
5. List and explain the different data types available in Python.
6. What are variables in Python, and how are they different from variables in other
programming languages?
7. Define expressions in Python and provide three examples.
8. Describe the different types of operators available in Python.
9. Explain what identifiers are in Python and the rules for naming them.
10. What are reserved words in Python? Provide a list of at least 10 reserved words.
11. Discuss the importance of indentation in Python programming.
12. Explain the different types of comments in Python and their uses.
13. How are strings represented in Python? Provide examples of string operations.
14. Describe the list data type in Python and how it is used.
15. What are tuples in Python? Explain with examples.
16. Define sets in Python and provide examples of set operations.
17. Explain dictionaries in Python and their typical uses.
18. List and explain the arithmetic operators in Python with examples.
19. What are comparison operators in Python? Provide examples.
20. Describe the logical operators in Python and their uses.
21. Explain bitwise operators in Python with suitable examples.
22. Discuss the different assignment operators in Python.
23. What are membership operators in Python? Provide examples.
24. Explain identity operators in Python and their typical usage.
25. How do you write multi-line comments in Python? Provide examples and discuss
their significance.
II UNIT Questions
1. Explain the purpose and usage of the if statement in Python. Provide examples of how
to use it to make simple decisions based on a single condition.
2. Describe the if-else statement in Python. How does it differ from the basic if statement,
and when would you use it? Give an example to illustrate its usage.
3. What are nested if statements in Python? Discuss the syntax and provide an example of
how you would use nested if statements to make complex decisions based on multiple
conditions.
4. Explain the if-elif-else ladder statement in Python. How does it allow you to handle
multiple mutually exclusive conditions, and how does it differ from using
nested if statements? Give an example to demonstrate its usage.
5. Discuss the while loop in Python. Explain its syntax, how to control the loop's
execution, and provide an example of using a while loop to repeatedly perform a task.
6. Describe the for loop in Python. How does it differ from the while loop, and when
would you choose to use one over the other? Give an example of using a for loop to
iterate over a sequence.
7. What are nested loops in Python? Explain the purpose and usage of nested loops, and
provide an example of a program that uses nested loops to perform a complex task.
8. Discuss the else clause in Python loops. How does it work, and what are some use cases
where you might employ it? Give an example to illustrate its usage.
9. Explain the break statement in Python loops. How does it allow you to exit a loop
prematurely, and what are some situations where you might use it? Provide an example.
10. Describe the continue statement in Python loops. How does it differ from
the break statement, and when would you use it? Give an example of using continue to
skip certain iterations of a loop.
11. What is the purpose of the pass statement in Python? Discuss how it can be used as a
placeholder in loops and other control structures, and provide an example of its usage.
12. Explain the concept of loop control statements in Python. Discuss the importance of
controlling the flow of execution within loops and provide examples of how to use loop
control statements effectively.
13. Describe the various math functions available in Python, such
as abs(), round(), min(), max(), and pow(). Discuss how you can use these functions
within loops to perform mathematical operations.
14. Discuss the random module in Python. Explain how to generate random numbers using
functions like random(), randint(), and randrange(), and provide examples of how you
might use random numbers within loops.
15. Explain the concept of user-defined functions in Python. Discuss the syntax for defining
a function, including the use of the def keyword, function parameters, and the function
body.
16. Describe the different types of function arguments in Python, such as positional
arguments, keyword arguments, and default arguments. Provide examples of how to
use each type of argument when calling a function.
17. Discuss the concept of return values in Python functions. Explain how to use
the return statement to send data back from a function, and provide examples of
functions that return different data types.
18. Explore the scope of variables in Python functions. Explain the difference between local
and global variables, and discuss how to access and modify global variables within a
function.
19. Describe the concept of recursive functions in Python. Explain how a function can call
itself to solve a problem, and provide an example of a recursive function that calculates
the factorial of a number.
20. Discuss the various string formatting techniques available in Python, such as using
the format() method, f-strings, and the % operator. Provide examples of how to use
these methods to create dynamic and readable string output.
21. Explain string comparison in Python. Describe how to use the comparison operators
(<, >, ==, etc.) to compare strings, and discuss the importance of case sensitivity in
string comparisons.
22. Explore string slicing in Python. Explain how to extract substrings from a larger string
using the slicing syntax, and provide examples of how to use slicing to manipulate and
extract specific parts of a string.
23. Discuss the split() and join() methods in Python strings. Explain how to use these
methods to break a string into a list of substrings and then reassemble them into a new
string, respectively. Give examples of practical use cases for these string operations.
24. Describe the strip(), lstrip(), and rstrip() methods in Python strings. Discuss how these
methods can be used to remove leading and/or trailing whitespace (or other characters)
from a string, and provide examples of their usage.
25. Explore the concept of negative indices in Python strings. Explain how to use negative
indices to access characters from the end of a string, and provide examples of how this
can be a useful technique for string manipulation.
III Unit

1. How do you create a tuple in Python?


2. What is the difference between a list and a tuple in Python?
3. How do you access elements in a tuple?
4. How do you slice a tuple in Python?
5. What is the output of t = (1, 2, 3); t?
6. How do you check if an element is in a tuple?
7. What is the output of t = (1, 2, 3); t?
8. How do you concatenate two tuples in Python?
9. What is the output of t = (1, 2, 3); t + (4, 5)?
10. How do you repeat a tuple in Python?
11. How do you create a list in Python?
12. How do you access elements in a list?
13. How do you slice a list in Python?
14. What is the output of l = [1, 2, 3]; l?
15. How do you check if an element is in a list?
16. What is the output of l = [1, 2, 3]; l?
17. How do you concatenate two lists in Python?
18. What is the output of l = [1, 2, 3]; l + [4, 5]?
19. How do you repeat a list in Python?
20. How do you create a dictionary in Python?
21. How do you add a key-value pair to a dictionary?
22. How do you replace a value in a dictionary?
23. What is the output of d = {'a': 1}; d['b'] = 2?
24. How do you check if a key exists in a dictionary?
25. How do you iterate over a dictionary in Python?
26. How do you create a set in Python?
27. How do you add an element to a set?
28. How do you check if an element is in a set?
29. What is the output of s = {1, 2, 3}; 4 in s?
30. How do you remove an element from a set?
31. What is a list comprehension in Python?
32. How do you create a list comprehension for a list of squares?
33. What is a set comprehension in Python?
34. How do you create a set comprehension for a set of even numbers?
35. What is a dictionary comprehension in Python?
36. How do you create a dictionary comprehension for a dictionary of squares?
37. How do you access elements using negative indices in Python?
38. What is the output of l = [1, 2, 3]; l[-1]?
39. How do you slice a list using negative indices?
40. What is the output of l = [1, 2, 3]; l[-2:]?
41. How do you slice a list in Python?
42. What is the output of l = [1, 2, 3]; l[1:3]?
43. How do you slice a tuple in Python?
44. What is the output of t = (1, 2, 3); t[1:3]?
45. How do you slice a string in Python?
46. What is the append() method in Python?
47. How do you use the append() method to add an element to a list?
48. What is the extend() method in Python?
49. How do you use the extend() method to add multiple elements to a list?
50. What is the insert() method in Python?
IV UNIT

1. What is the purpose of using functions in Python?


2. What is the syntax for defining a function in Python?
3. Explain the difference between a parameter and an argument in a function.
4. What are positional arguments in Python functions? Give an example.
5. What are keyword arguments in Python functions? How do they differ from
positional arguments?
6. How do you define a function with default parameter values? When are
default arguments used?
7. Explain arbitrary positional arguments (*args) in Python functions. How are
they used?
8. Explain arbitrary keyword arguments (**kwargs) in Python functions. How do
they differ from *args?
9. What is the scope of variables in Python? Explain local and global scope.
10. How do you access a global variable inside a function in Python?
11. Can you modify the value of a global variable inside a function? If yes, how?
12. Explain the LEGB rule for variable scope in Python.
13. What happens when you have a local variable with the same name as a global
variable?
14. What is recursion in programming? Give an example of a recursive function in
Python.
15. What are the advantages and disadvantages of using recursion?
16. Explain the concept of a base case in a recursive function.
17. What is the purpose of lambda functions in Python?
18. How do you define a lambda function? Give an example.
19. What are the limitations of lambda functions compared to regular functions?
20. What is the purpose of using files in Python?
21. Explain the different modes for opening a file in Python (e.g., r, w, a, etc.).
22. How do you open a file using the open() function in Python?
23. Explain the read(), readline(), and readlines() methods for reading from a file.
24. How do you write data to a file using the write() and writelines() methods?
25. What is the purpose of the close() method for files? Why is it important to
close a file after using it?
V Unit

1. What is the purpose of NumPy in Python?


2. How do you create a 1-dimensional NumPy array from a Python list?
3. Explain the concept of an N-dimensional array in NumPy.
4. What are the different data types supported by NumPy arrays?
5. How do you convert between different data types in a NumPy array?
6. Describe the process of performing arithmetic operations on NumPy arrays.
7. What is the difference between element-wise and matrix multiplication in
NumPy?
8. How do you access and modify individual elements in a NumPy array using
indexing?
9. Explain the concept of slicing in NumPy arrays.
10. What is the purpose of boolean indexing in NumPy?
11. How do you transpose a NumPy array?
12. Describe the process of swapping axes in a multi-dimensional NumPy array.
13. What are universal functions in NumPy?
14. How do you apply a universal function to a NumPy array?
15. Explain the concept of broadcasting in NumPy.
16. What are some commonly used mathematical universal functions in NumPy?
17. How do you perform statistical calculations on NumPy arrays?
18. Describe the process of sorting a NumPy array.
19. How do you find unique elements in a NumPy array?
20. Explain the concept of set logic operations in NumPy.
21. What is the purpose of data visualization in data analysis?
22. How do you create a line plot using Matplotlib?
23. Explain the concept of scatter plots and their use in data analysis.
24. How do you create a histogram to visualize the distribution of data?
25. Describe the process of creating a bar chart to compare categorical data.

You might also like