The document contains questions and answers for a Class 8 Computer Science curriculum, focusing on Python programming concepts. It includes multiple choice questions, short answer questions, and long answer questions covering topics like loops, functions, and data types. Key concepts such as recursion, the difference between lists and tuples, and the purpose of the MIT App Inventor platform are also addressed.
The document contains questions and answers for a Class 8 Computer Science curriculum, focusing on Python programming concepts. It includes multiple choice questions, short answer questions, and long answer questions covering topics like loops, functions, and data types. Key concepts such as recursion, the difference between lists and tuples, and the purpose of the MIT App Inventor platform are also addressed.
1. What is the correct syntax to start a loop in Python? Answer: b) while condition:
2. What will be the output of print(10 // 3)?
Answer: a) 3
3. Which keyword is used to define a function in Python?
Answer: c) def
4. What does the return statement do in a function?
Answer: b) Returns a value to the caller
5. What is the output of the following?
x = [1, 2, 3] x.append([4, 5]) print(x) Answer: a) [1, 2, 3, [4, 5]]
6. Which of the following is an immutable data type?
Answer: c) Tuple
7. What is the purpose of a docstring in Python?
Answer: a) To document the code
8. Which method is used to remove an item from a list?
Answer: d) Both b and c (remove(), pop())
9. What does x[::-1] do in Python when x='Hello'?
Answer: a) Returns 'olleH'
10. What is the purpose of the MIT App Inventor platform?
Answer: b) To develop mobile applications
Section B: Short Answer Questions & Answers
11. What is the difference between a list and a tuple in Python? Answer: Lists are mutable, whereas tuples are immutable.
12. What are the advantages of using functions in Python?
Answer: Functions promote reusability, modularity, and easier debugging.
13. Define recursion with an example.
Answer: Recursion is when a function calls itself. Example: def factorial(n): if n == 0: return 1 return n * factorial(n-1)
Section C: Long Answer Questions & Answers
21. Explain 'for' and 'while' loops in Python with examples. Answer: The 'for' loop is used when the number of iterations is known, whereas 'while' loops execute until a condition is false. Example: for i in range(5): print(i) while x < 5: print(x) x += 1
22. Write a Python program to check if a number is prime.
Answer: Python Code: def is_prime(n): for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True print(is_prime(7)) # Output: True