# - CBSE Class 12 Computer Sci
# - CBSE Class 12 Computer Sci
---
**1 Mark:**
➡ *What is the difference between a function and a module?*
✅ **Answer:** A **function** is a block of reusable code, whereas
a **module** is a file containing multiple functions, classes, and
variables.
**2 Marks:**
➡ *Differentiate between `return` and `print()` in Python.*
✅ **Answer:**
- `return`: Sends value back to the function caller, terminates
function execution.
- `print()`: Displays output on screen but does not return a
value.
**3 Marks:**
➡ *Write a Python function to find the factorial of a number using
recursion.*
```python
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
---
**1 Mark:**
➡ *What is the difference between `r+` and `w+` file modes?*
✅ **Answer:**
- `"r+"`: Read and write; does **not** create file if absent.
- `"w+"`: Read and write; **creates file** if absent and overwrites
existing content.
**2 Marks:**
➡ *Explain the use of `with open()` statement.*
✅ **Answer:** The `with open()` statement ensures the file is
properly closed after use, reducing the risk of data corruption.
**3 Marks:**
➡ *Write a Python program to read a text file and display its
content.*
```python
with open("sample.txt", "r") as file:
content = file.read()
print(content)
```
---
**1 Mark:**
➡ *What is the purpose of the `GROUP BY` clause?*
✅ **Answer:** It groups rows that have the same values in
specified columns and is used with aggregate functions like
`SUM()`, `COUNT()`.
**2 Marks:**
➡ *Write an SQL query to display names of students who scored
above 90 in Mathematics.*
```sql
SELECT name FROM students WHERE Mathematics > 90;
```
**3 Marks:**
➡ *Explain `PRIMARY KEY` and `FOREIGN KEY` with an
example.*
✅ **Answer:**
- **Primary Key:** A unique identifier for records in a table.
- **Foreign Key:** A field in one table that references the primary
key in another table.
```sql
CREATE TABLE Students (
ID INT PRIMARY KEY,
Name VARCHAR(50)
);
---
**1 Mark:**
➡ *What is De Morgan's Theorem?*
✅ **Answer:**
- (A.B)' = A' + B'
- (A + B)' = A' . B'
**2 Marks:**
➡ *Simplify the Boolean Expression: A + AB*
✅ **Answer:**
A + AB = A(1 + B) = A(1) = **A**
**3 Marks:**
➡ *Draw the logic circuit for the Boolean expression: (A + B)' . C*
✅ **Diagram:**
_(Include a NAND & AND Gate representation)_
---
---
---
This markdown-friendly format can be copied into **Google
Docs/Word → Export as PDF** for easy printing!