Class 12 Computer Science Practical File
Q1. Write a program to find the factorial of a number.
Code:
n = int(input("Enter a number: "))
fact = 1
for i in range(1, n+1):
fact *= i
print("Factorial:", fact)
Process:
1. Input a number from the user (e.g., 5).
2. Initialize fact = 1.
3. Loop from 1 to n and multiply each value with fact.
4. Print the final value.
Output:
Enter a number: 5
Factorial: 120
Q2. SQL – Write a query to display students with marks > 80.
Query:
SELECT Name, Marks FROM Student WHERE Marks > 80;
Process:
1. Student table has columns (RollNo, Name, Marks, Stream).
2. Apply WHERE Marks > 80 to filter students.
3. Display Name and Marks of qualifying students.
Output:
Name Marks
Ravi 85
Priya 92