DEDRAJ SEWALI DEVI TODI
DAV-KVB SCHOOL
Biratnagar-11, Morang, Nepal
Report File Of Computer
Submitted By- Shreyas Mallick
Submitted To – Mr. Ashish Ashk
Class : XII-Science
Roll No: 21
1
PYTHON PROGRAMMING
Finding root of Quadratic Equation In Python
def findRoots(a, b, c):
d = (b*b - 4*a*c)**0.5
x1 = (-b + d)/(2*a)
x2 = (-b - d)/(2*a)
print('\nROOTS OF GIVEN QUADRATIC EQUATIONS ARE:')
print('x1: {0}'.format(x1))
print('x2: {0}'.format(x2))
print('Solving ax^2 + bx + c =0')
a = float(input('Enter the value of a: '))
b = float(input('Enter the value of b: '))
c = float(input('Enter the value of c: '))
findRoots(a,b,c)
Output:-
2
Check Palindrome Number In Python
number = int(input('Enter Number: '))
copy = number
reverse = 0
while number != 0:
remainder = number%10
reverse = reverse *10 + remainder
number = number//10
if copy == reverse:
print('%d is PALINDROME' %(copy))
else:
print('%d is NOT PALINDROME' %(copy))
Output:-
3
Check Prime Number In Python
number = int(input('Enter number: '))
shreyas= 1
for i in range(2,int(number/2)):
if number%i==0:
flag=0
break
if shreyas==1 and number>=2:
print('It is a Prime Number')
else:
print('It is not Prime Number')
Output:-
4
To Generate Fibonacci Series In Python
def generate_fibonacci(n):
a, b = 0, 1
while a < n:
print(a, end=', ')
next_num = a + b
a, b = b, next_num
output = int(input('Enter maximum term of Fibonacci series: '))
generate_fibonacci(output)
Output:-
5
Print 1-101-10101 Binary Number Pyramid
n = int(input("Enter number of lines of pattern: "))
for i in range(1,n+1):
for j in range(1, n-i+1):
print(" ", end="")
for k in range(1,2*i):
print(k%2, end="")
print()
Output:-
6
Print Nepal Flag Using Stars In Python
def triangleShape(n):
for i in range(n):
for k in range(i+1):
print('*',end=' ')
print()
def poleShape(n):
for i in range(n):
print('*')
row = int(input('Enter number of rows: '))
triangleShape(row)
triangleShape(row)
poleShape(row)
Output:
7
Calculate Area and Circumference Of Circle
import math
radius = float(input("Enter the radius of the circle: "))
area = math.pi * radius ** 2
circumference = 2 * math.pi * radius
print("Area of the circle:",area)
print("Circumference of the circle:",circumference)
Output:-
8
Calculate Simple Interest In Python
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest (in %): "))
time = float(input("Enter the time (in years): "))
simple_interest = (principal * rate * time) / 100
print(f"The simple interest is:",simple_interest)
Output:-
9
Find The Factorial Of a Number Using Loop
number = int(input("Enter a number: "))
factorial = 1
for i in range(1, number + 1):
factorial *= i
print(f"The factorial of {number} is {factorial}.")
Output:-
10
Find The Reverse Of Given Number In Python
number = int(input('Enter Number: '))
copy = number
reverse = 0
while number != 0:
remainder = number%10
reverse = reverse *10 + remainder
number = number//10
print(“The reverse is:”,reverse)
Output:-
11
Covert Temperature in Celsius To Fahrenheit In Python
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 1.8) + 32
print("Temperature in Fahrenheit is:",fahrenheit)
Output:-
12
MYSQL
1.Table To Work With
-SELECT All Data from the Table
-SELECT Specific Columns
13
-UPDATE Data in the Table
-SELECT Data with a Condition (WHERE)
-DELETE Data from the Table
14
2. Table To Work With
-Select Employees from a Specific Department
-Select Employees with Salary Above a Certain Amount
-Select Employees with Joining Date After a Certain Date
15
-Select Employee Names and Their Departments
-Count the Number of Employees in Each Department
16
3. Tables To Work With
-Get all students with their courses and library IDs:
17
-Find students who are enrolled in a specific course
- Find students who are not enrolled in any course
18
-Get the list of students and courses they are enrolled in,
sorted by student name
- Get a list of students who are enrolled in more than one
course
19
4. Table To Work With
-Get a list of all teachers along with their subjects and
joining dates
20
-Get a list of all teachers and their class times sorted by
time
-Find the teacher who teaches a specific subject
21
-Find teachers whose class time is before 12:00 PM
-Find the teachers who teach more than one subject
22
5.Table to work with
-Find players who are Batsmen
23
-Get players who are All-Rounders
- Get the player who bats in the 5th Down position
24
- All players sorted by their position
-Get the total number of players in each type
25
MYSQL CONNECTIVITY
1. To Create Table
import mysql.connector
conn = mysql.connector.connect(
host="localhost",
user="root",
password="admin"
cursor = conn.cursor()
cursor.execute("CREATE DATABASE IF NOT EXISTS School")
cursor.execute("USE School")
cursor.execute("""
CREATE TABLE IF NOT EXISTS Students (
StudentID INT PRIMARY KEY,
Name VARCHAR(50), Output:
Age INT,
Grade CHAR(1)
""")
print("Database and table created successfully!")
cursor.close()
conn.close()
26
2. To Insert Data
import mysql.connector
conn = mysql.connector.connect(
host="localhost",
user="root",
password="admin",
database="School"
cursor = conn.cursor()
cursor.execute("""
INSERT INTO Students (StudentID, Name, Age, Grade)
VALUES (%s, %s, %s, %s)
""", (6, 'Frank Castle', 24, 'A'))
cursor.execute("""
INSERT INTO Students (StudentID, Name, Age, Grade)
VALUES (%s, %s, %s, %s)
""", (7, 'Grace Hopper', 22, 'B')) Output:
conn.commit()
print("Data inserted successfully!")
cursor.close()
conn.close()
27