*1. What is the output of `print("Hello" + 1)` in Python?*
ANS: Error (TypeError)
*2. What is the purpose of the `break` statement in a loop?*
ANS: To exit the loop prematurely
*3. Write a Python program to print the first 5 natural numbers.*
ANS: `for i in range(1, 6): print(i)`
*4. What is the difference between `=` and `==` operators?*
ANS: `=` is for assignment, `==` is for comparison
*5. What is the output of `print(5 % 2)`?*
ANS: 1
*6. Write a Python function to check if a number is even.*
ANS: `def is_even(n): return n % 2 == 0`
*7. What is the purpose of the `continue` statement in a loop?*
ANS: To skip the current iteration and move to the next one
*8. What is the output of `print("Hello".upper())`?*
ANS: HELLO
*9. Write a Python program to calculate the sum of two numbers.*
ANS: `a = 5; b = 3; print(a + b)`
*10. What is the difference between a list and a tuple in Python?*
ANS: Lists are mutable, tuples are immutable
*11. What is the time complexity of searching an element in a sorted array?*
ANS: O(log n) using binary search
*12. What is a linked list?*
ANS: A data structure in which elements are linked using pointers
*13. Write a Python program to implement a stack using a list.*
ANS: `stack = []; stack.append(1); stack.pop()`
*14. What is a queue?*
ANS: A First-In-First-Out (FIFO) data structure
*15. What is the difference between a stack and a queue?*
ANS: Stack is LIFO, queue is FIFO
ANS: Error (TypeError)
*2. What is the purpose of the `break` statement in a loop?*
ANS: To exit the loop prematurely
*3. Write a Python program to print the first 5 natural numbers.*
ANS: `for i in range(1, 6): print(i)`
*4. What is the difference between `=` and `==` operators?*
ANS: `=` is for assignment, `==` is for comparison
*5. What is the output of `print(5 % 2)`?*
ANS: 1
*6. Write a Python function to check if a number is even.*
ANS: `def is_even(n): return n % 2 == 0`
*7. What is the purpose of the `continue` statement in a loop?*
ANS: To skip the current iteration and move to the next one
*8. What is the output of `print("Hello".upper())`?*
ANS: HELLO
*9. Write a Python program to calculate the sum of two numbers.*
ANS: `a = 5; b = 3; print(a + b)`
*10. What is the difference between a list and a tuple in Python?*
ANS: Lists are mutable, tuples are immutable
*11. What is the time complexity of searching an element in a sorted array?*
ANS: O(log n) using binary search
*12. What is a linked list?*
ANS: A data structure in which elements are linked using pointers
*13. Write a Python program to implement a stack using a list.*
ANS: `stack = []; stack.append(1); stack.pop()`
*14. What is a queue?*
ANS: A First-In-First-Out (FIFO) data structure
*15. What is the difference between a stack and a queue?*
ANS: Stack is LIFO, queue is FIFO