Python questions
Python questions
Python questions
7. What is the difference between a compiler and an interpreter? How does Python execute code?
9. What do you mean by a variable? Does Python allow explicit declaration of variables? Justify.
15. List any four features of Python and explain any two.
23. Explain the use of strings in Python. Also, explain ‘+’ and ‘*’ w.r.t. strings.
26. Describe the Python execution modes (Interactive vs. Script mode).
1. What are the different types of operators in Python? Explain with examples.
2. Explain membership (in, not in) and identity (is, is not) operators.
8. Write a Python program to find the largest of three numbers using if-elif-else.
10. Write a Python program to print the first 10 Fibonacci numbers using a loop.
18. Can we use the else keyword with loops? Justify your answer.
19. Write Python code to find the greatest among four numbers.
28. How do break and continue statements work in loops? Provide examples.
10. What are sets? Explain set operations (union, intersection, difference).
11. Write a Python program to find the second largest element in a list.
12. Explain the count() and index() methods in tuples with examples.
468
10 12 14 16 18
14. How do sets handle duplicate elements? Write a program to add/remove elements.
17. Write a program to access the 32nd element from a list and update it.
19. Explain any four built-in methods of lists in Python with examples.
22. Explain built-in functions for tuples and describe any four.
23. Can we iterate through a set using a for loop? Justify your answer.
27. Explain different ways and functions to remove key-value pairs from a dictionary.
o append()
o insert()
o Set Union
o Set Intersection