Professional Documents
Culture Documents
Science (083)
Assignment
Work
Made by:
Tanu shree
Class: XII-A
Roll No. ______
Python Programming
1. Write a program in python to check a number whether it is prime or not
x=(1+r/100)**t
CI= p*x-p
print("Compound interest is : ", round(CI,2))
var=True
while var:
choice=int(input("Press-1 to find the ordinal value of a character \nPress-2 to find a character of a
value\n"))
if choice==1:
ch=input("Enter a character : ")
print(ord(ch))
elif choice==2:
val=int(input("Enter an integer value: "))
print(chr(val))
else:
print("You entered wrong choice")
def factorial(n):
if n == 1:
return n
else:
return n*factorial(n-1)
#__main__
if y==True:
print("String is Palindrome")
else:
print("String is Not Palindrome")
import numpy as np
import csv
with open('emp.csv') as csvfile:
myreader = csv.reader(csvfile,delimiter=',')
count=0
print("%10s"%"EMPNO","%20s"%"EMP NAME","%10s"%"SALARY")
print("==================================================")
for row in myreader:
print("%10s"%row[0],"%20s"%row[1],"%10s"%row[2])
count+=1
print("==================================================")
print("%30s"%"TOTAL RECORDS :", count)
print("==================================================")
MYSQL Practical
14. Creating and inserting the tables
Create table (table name)
(<column name><data type>[(size)]
18. COUNT
19. SELECTING THE PARTICULAR COLUMN
20. Create a table name Emp with following structure (EmpID primary key)
Write a query to display all the records with all the columns.
21. Write a query to display EmpName and Sal of employees whose salary are greater
than or equal to 2200.
22.Display the distinct designation in the organization.
24. Consider the following tables SCHOOL and ADMIN. Write sql commands for the
statement 1 to 5.
25. To display TeacherName, Periods of all teachers whose working experience is more
than 10 years.
26. To display teachername, periods of all teachers whose periods less than 25.
27. To display teachername, gender and subject of all teachers who have joined the
school after 01/01/1999.
MySql-Python-Connector
29. Create a Python program that connects MySQL database by creating a table
Teacher_Detail in database School.
import mysql.connector as m
mdb = m.connect(host="localhost",user="root",passwd ="tiger",database ="school")
print(mdb)
cr = mdb.cursor();
cr.execute("Create table Teacher_Detail(Id char(4) Primary key, Name varchar(15), price decimal(5,2))")
print("table created succesfully")
cr.execute("Show tables")
for x in cr:
print(x)
30. Create a Python program that connects MySQL database by inserting 5 values in a
table Student in database School.
import mysql.connector as m
mdb=m.connect(host="localhost",user="root", passwd="tiger", database="school")
print(mdb)
cr=mdb.cursor();
cr.execute("Insert into student values(11,'Janvi',390.5)")
cr.execute("Insert into student values(12,'Himani',450.0)")
cr.execute("Insert into student values(13,'Naincy',400.00)")
cr.execute("Insert into student values(14,'Harish',460.5)")
cr.execute("Insert into student values(15,'Abhay',375.5)")
mdb.commit()
jumnhygtfz print("Record Inserted succesfully")
cr.execute("Select * from student")
rec=cr.fetchall()
for x in rec:
print(x)
print(cr.rowcount,"Record Inserted")
mdb.close()
*****THANK YOU*****