Computer Practical
Computer Practical
CLASS – XII
1. Python Programs
a) Write a program to find whether an inputted number is perfect or not.
b) Write a Program to check if the entered number is Armstrong or not.
c) Write a Program to find factorial of the entered number.
d) Write a Program to enter the number of terms and to print the Fibonacci
Series.
e) Write a Program to enter the string and to check if it’s palindrome or not
using loop.
f) Write a Program to enter the numbers in a list using split () and to use
all the functions related to list
g) Write a Program to enter the numbers in a list using split () and to use
all the functions related to list
h) Write a Program to find factorial of entered number using user-defined
module fact().
i) Write a Program to read data from data file and show Data File Handling
related functions utility in python.
j) Write a Program to read data from data file in append mode and use
writeLines function utility in python.
k) Write a Program to read data from data file in read mode and count the
particular word occurrences in given string, number of times in python.
l) Write a Program to read data from data file in read mode and append the
words starting with letter ‘T’ in a given file in python.
2. SQL Queries
i) The employees table has the following structure:
Table: employees
id first_name last_name department salary
1 John Doe HR 50000
2 Jane Smith IT 60000
3 Mike Johnson Finance 55000
4 Emily Davis IT 62000
5 Sarah Wilson HR 52000
Table: departments
department_id department_name
1 HR
2 IT
3 Finance
a) Select first and last names of all employees with their department name:
SELECT e.first_name, e.last_name, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id;
b) Update an employee's salary:
UPDATE employees
SET salary = 63000
WHERE first_name = 'Emily' AND last_name = 'Davis';
c) Delete employees with a salary less than 52000:
DELETE FROM employees WHERE salary < 52000;
d) Find the highest salary per department:
SELECT d.department_name, MAX(e.salary) AS highest_salary
FROM employees e
JOIN departments d ON e.department_id = d.department_id
GROUP BY d.department_name;
3. Python with MYSQL
a. Insert data into mysql database using python
import mysql.connector
# Data to insert
data_to_insert = (1, "John Doe", 22)