Python Course: Questions and Answers
2-Mark Questions (50)
1. What is Python?
2. Who developed Python and when?
3. What is a variable in Python?
4. What does the `#` symbol denote in Python?
5. What is the purpose of the `input()` function?
6. What is the difference between `=` and `==`?
7. What is a loop?
8. Give an example of a conditional statement.
9. Define a string in Python.
10. What is the syntax to define a function in Python?
11. What is a list in Python?
12. What is a dictionary?
13. What is a tuple?
14. What is the difference between mutable and immutable objects?
15. How do you access an element in a list?
16. What is slicing in Python?
17. What is the use of the `len()` function?
18. How do you declare a variable in Python?
19. What is an algorithm?
20. What is indentation in Python?
21. What is the purpose of the `range()` function?
22. What is a syntax error in Python?
23. What is a runtime error?
24. What is typecasting in Python?
25. What is the difference between a list and a tuple?
26. What is the use of the `break` statement?
27. What is the use of the `continue` statement?
28. What is the output of `print(5//2)`?
29. What is a string literal?
30. What are keywords in Python?
31. What is the use of the `in` keyword?
32. What is a comment?
33. What is the difference between `is` and `==` in Python?
34. What is the use of the `not` operator?
35. What is the syntax for a while loop in Python?
36. What is the difference between a for loop and a while loop?
37. What is the `pass` statement?
38. What are local variables in Python?
39. What are global variables in Python?
40. What is the `del` keyword?
41. What is a lambda function?
42. What is recursion?
43. What is the `return` statement used for?
44. What is a module in Python?
45. What is the difference between `import` and `from` in Python?
46. What is the purpose of the `dir()` function?
47. What is the `help()` function in Python?
48. What is the purpose of the `open()` function?
49. What is the difference between `read()` and `readline()`?
50. What are Python packages?
6-Mark Questions (30)
1. Explain the steps to install Python on Windows.
2. Write a Python program to calculate the factorial of a number using a loop.
3. How do you use a try/except block in Python?
4. Explain the use of conditional statements with examples.
5. Write a Python program to check if a given number is prime.
6. What is the difference between Python 2 and Python 3?
7. Write a Python program to reverse a string using slicing.
8. What is the difference between `append()` and `extend()` in lists?
9. Write a Python program to count vowels in a string.
10. Explain the use of the `with` statement in file handling.
11. Write a Python program to find the largest number in a list.
12. Explain the working of a for loop with an example.
13. Write a Python program to find the sum of squares of the first N natural
numbers.
14. Explain the difference between positional and keyword arguments in
functions.
15. What is the purpose of the `*args` and `**kwargs` in Python functions?
16. Explain the use of list comprehensions with an example.
17. Write a Python program to remove duplicates from a list.
18. What are Python's built-in data types?
19. Explain the difference between shallow and deep copying.
20. Write a Python program to merge two dictionaries.
21. What is the difference between `pop()` and `remove()` in lists?
22. Explain the use of decorators in Python.
23. Write a Python program to sort a dictionary by its keys.
24. Explain how Python handles memory management.
25. Write a Python program to find the intersection of two lists.
26. What are Python's built-in string methods?
27. Explain the difference between mutable and immutable objects with
examples.
28. Write a Python program to check if two strings are anagrams.
29. What are the key differences between Python and other programming
languages?
30. Write a Python program to create a simple calculator.
8-Mark Questions (30)
1. Write a Python program to check if a given string is a palindrome.
2. Explain the key differences between Python lists and NumPy arrays.
3. Write a Python program to fetch data from an API and display the result.
4. Explain the working of the JSON module in Python.
5. Write a Python program to scrape a website using BeautifulSoup.
6. Explain the REST architecture and how it is used in Python APIs.
7. Write a Python program to read and write data from a CSV file.
8. Explain the use of Python's `os` module with examples.
9. Write a Python program to create and manipulate a Pandas DataFrame.
10. Explain the use of the `re` module for regular expressions in Python.
11. Write a Python program to connect to a MySQL database using the
`[Link]` module.
12. Explain the difference between synchronous and asynchronous
programming in Python.
13. Write a Python program to create a bar chart using Matplotlib.
14. Explain the importance of exception handling in web scraping.
15. Write a Python program to parse and extract data from XML.
16. Explain how Python handles garbage collection.
17. Write a Python program to implement a simple REST API using Flask.
18. Explain the purpose and use of Python virtual environments.
19. Write a Python program to perform CRUD operations on a SQLite database.
20. Explain the use of threading in Python with examples.
21. Write a Python program to process and visualize large datasets using
Python libraries.
22. Explain the concept of closures in Python with examples.
23. Write a Python program to encrypt and decrypt data using the
`cryptography` library.
24. Explain the use of context managers in Python.
25. Write a Python program to analyze text sentiment using NLTK.
26. Explain the difference between multi-threading and multi-processing in
Python.
27. Write a Python program to automate email sending using the `smtplib`
module.
28. Explain the use of Python for machine learning with an example.
29. Write a Python program to create a GUI application using Tkinter.
30. Explain the use of the `asyncio` module in Python.