Skip to content

Commit b8bf0d5

Browse files
committed
first commit
0 parents  commit b8bf0d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1975
-0
lines changed

Diff for: Python.zip

27.5 KB
Binary file not shown.

Diff for: database/emp.csv

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ID,Name,Designation,Salary
2+
101,ABC,IT,50000
3+
102,MNO,HR,40000
4+
103,PQRS,Account,30000
5+
104,XYZ,Finance,20000

Diff for: database/prg4.csv

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(101, 'vishal', 'IT', 15000)
2+
(101, 'XYZ', 'HR', 10000)

Diff for: database/prg_1.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import MySQLdb
2+
3+
while True:
4+
print('1-Add Record')
5+
print('2-Modify Record')
6+
print('3-Display Record')
7+
print('4-Delete Record')
8+
ch=int(input('Enter choice:'))
9+
conn=MySQLdb.connect(host='localhost',database='python',user='root',password='admin')
10+
cursor=conn.cursor()
11+
12+
if ch==1:
13+
str="insert into employee values(%d,'%s','%s',%d)"
14+
id=int(input('Enter ID: '))
15+
name=input('Enter Name: ')
16+
designation=input('Enter Designation: ')
17+
salary=int(input('Enter Salary: '))
18+
args=(id,name,designation,salary)
19+
cursor.execute(str % args)
20+
conn.commit()
21+
print("\nRow inserted\n")
22+
elif ch==2:
23+
str="update employee set salary=salary+1000 where id='%d'"
24+
sal=int(input('Enter ID where you want to update salary: '))
25+
args=(sal)
26+
cursor.execute(str % args)
27+
conn.commit()
28+
print("\nRecord Modified\n")
29+
elif ch==3:
30+
str="select * from employee"
31+
cursor.execute(str)
32+
row=cursor.fetchone()
33+
while row is not None:
34+
print("\n",row)
35+
row=cursor.fetchone()
36+
elif ch==4:
37+
str="delete from employee where id=%d"
38+
id=int(input('Enter ID for deletion: '))
39+
args=(id)
40+
cursor.execute(str % args)
41+
conn.commit()
42+
print("\nRecord Deleted\n")
43+
else:
44+
break;
45+
cursor.close()
46+
conn.close()

Diff for: database/prg_2.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import MySQLdb
2+
3+
conn=MySQLdb.connect(host='localhost',database='python',user='root',password='admin')
4+
cursor=conn.cursor()
5+
cursor.execute("select * from employee")
6+
rows=cursor.fetchall()
7+
print('Total number of rows=',cursor.rowcount)
8+
print("%-3s %-10s %-10s %-6s"%("ID","Name","Designation","Salary"))
9+
for row in rows:
10+
id=row[0]
11+
name=row[1]
12+
designation=row[2]
13+
salary=row[3]
14+
print('%-3d %-10s %-10s %-6d'%(id,name,designation,salary))
15+
cursor.close()
16+
conn.close()

Diff for: database/prg_3.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import MySQLdb
2+
import pandas as pd
3+
4+
f=pd.read_csv("emp.csv")
5+
c1=dict(f[['id','name','designation','salary']])
6+
print(f)
7+
for line in f:
8+
print(line)
9+
c1[id]=line[0]
10+
name=line[1]
11+
designation=line[2]
12+
salary=line[3]
13+
14+
conn=MySQLdb.connect(host='localhost',database='python',user='root',password='admin')
15+
cursor=conn.cursor()
16+
str="insert into employee values(%d,'%s','%s',%d)"
17+
args=(c1['id'],c1['name'],c1['designation'],c1['salary'])
18+
cursor.execute(str % args)
19+
conn.commit()

Diff for: database/prg_4.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import MySQLdb
2+
3+
conn=MySQLdb.connect(host='localhost',database='python',user='root',password='admin')
4+
cursor=conn.cursor()
5+
cursor.execute("select * from employee")
6+
rows=cursor.fetchone()
7+
f=open("prg4.csv","w")
8+
while rows is not None:
9+
f.write(str(rows))
10+
f.write('\n')
11+
rows=cursor.fetchone()

Diff for: prg1.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cel=float(input("Enter Celsius :"));
2+
fa=cel*9/5+32;
3+
print("Fahrenheit ",fa);
4+
fa=float(input("Enter Fahrenheit :"))
5+
cel=(fa-32)*5/9;
6+
print("Celsius ",cel);

Diff for: prg10.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def histogram(num):
2+
for i in num:
3+
print("x"*i);
4+
5+
6+
numbers=[];
7+
end=int(input("Enter length of list :"));
8+
for i in range(end):
9+
num=int(input("Enter value :"));
10+
numbers.append(num);
11+
print(numbers);
12+
histogram(numbers);
13+

Diff for: prg11.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def fibonacci(no):
2+
if no<=1:
3+
return 1;
4+
else:
5+
temp=fibonacci(no-1)+fibonacci(no-2);
6+
if temp<num:
7+
return temp;
8+
else:
9+
exit();
10+
11+
num=int(input("Enter number :"));
12+
for i in range(1,num+1):
13+
14+
print(fibonacci(i));

Diff for: prg12.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def factorial(no):
2+
if no == 0:
3+
return 1;
4+
else:
5+
return no * factorial(no-1);
6+
7+
num=int(input("Enter number :"));
8+
for i in range(1,num+1):
9+
print("Factorial of ",i," is ",factorial(i));

Diff for: prg13.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
file=open("prg13.txt","w")
2+
3+
file.write('1st line \n')
4+
file.write('2nd line \n')
5+
file.write('3rd line \n')
6+
file.write('4th line \n')
7+
file.writelines("See you soon! \n Over and out.")
8+
9+
file=open("prg13.txt","r")
10+
# print("Readline :")
11+
# line=file.readline()
12+
# print(line)
13+
14+
# print("Readlines :")
15+
# line=file.readlines()
16+
# for li in line:
17+
# print(li,end="")
18+
19+
print("Read:")
20+
l=file.read().splitlines();
21+
print(l)
22+
file.close();

Diff for: prg13.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1st line
2+
2nd line
3+
3rd line
4+
4th line
5+
See you soon!
6+
Over and out.

Diff for: prg14.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
file=open("prg14.txt","r")
2+
3+
emp_no=int(input("Enter Emp_no :"))
4+
print("\n{:8} {:8} {:10} {:10} {:10} {:8} {:10}".format("Emp_no","Name","Dept_no","Basic","DA","HRA","Conveyance"))
5+
for line in file:
6+
value=line.split()
7+
if(str(emp_no)==value[0]):
8+
for i in value:
9+
print(i.ljust(10),end="")
10+
print("\n")
11+
12+
file.seek(0)
13+
14+
dept_no=int(input("Enter Dept_no :"))
15+
print("\n{:8} {:8} {:10} {:10} {:10} {:8} {:10}".format("Emp_no","Name","Dept_no","Basic","DA","HRA","Conveyance"))
16+
for line in file:
17+
value=line.split()
18+
if(str(dept_no)==value[2]):
19+
for i in value:
20+
print(i.ljust(10),end="")
21+
print("\n")

Diff for: prg14.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1001 ABC 101 10000 2000 3000 1000
2+
1002 PQR 102 15000 3000 2000 1000
3+
1003 MNO 103 20000 1000 3000 2000
4+
1004 UVW 104 15000 1000 2000 3000
5+
1005 XYZ 105 30000 2000 2000 2000

Diff for: prg15.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os.path
2+
import random
3+
4+
class reserve:
5+
6+
def reserveticket(self):
7+
li=[]
8+
file=open("prg15.txt",'a')
9+
name=input("Input your name :")
10+
date=input("Enter the date dd/mm/yy format :")
11+
start=input("Enter the start city :")
12+
end=input("Enter the end city :")
13+
pnr=str(random.randint(1000000000,20000000000))
14+
li.append(name)
15+
li.append(date)
16+
li.append(start)
17+
li.append(end)
18+
li.append(pnr)
19+
for line in li:
20+
file.write(str(line)+" ")
21+
file.write("\n")
22+
file.close()
23+
24+
def get_ticket(self):
25+
file=open("prg15.txt",'r')
26+
dat=input("Enter today date :")
27+
data=[]
28+
data=file.readlines()
29+
print("Details".center(50,"#"))
30+
print("\n{:10} {:10} {:10} {:10} {:10}".format("Name","Date","Start","End","PNR"))
31+
for line in data:
32+
value=line.split()
33+
if dat==value[1]:
34+
for i in value:
35+
print(i.ljust(10),end="")
36+
print("\n")
37+
38+
"""
39+
if os.path.isfile("prg15.txt"):
40+
print("File already exist")
41+
else:
42+
file=open("prg15.txt","w")
43+
"""
44+
ch=-1
45+
while(ch!=0):
46+
print("1 - Booking ticket\n2 - Information of todays ticket\n0 - Exit\n")
47+
ch=int(input("Enter choice :"))
48+
r=reserve()
49+
if(ch==1):
50+
r.reserveticket()
51+
elif(ch==2):
52+
r.get_ticket()
53+
elif(ch==3):
54+
sys.Exit()

Diff for: prg15.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vishal 17/10/19 ahm raj 2025986309
2+
joshi 15/10/19 raj ahm 18901129171
3+
bhargav 17/10/19 ahm bha 5415806533
4+
vhjoshi 17/10/19 raj bhav 4199066872

Diff for: prg16.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import os.path
2+
from datetime import date
3+
4+
class library:
5+
6+
def issue_book(self):
7+
li=[]
8+
file=open("prg16.txt",'a')
9+
name=input("Enter Student name :")
10+
dat=input("Enter date(dd/mm/yy) :")
11+
book_id=input("Enter Book ID :")
12+
book_name=input("Enter Book name :")
13+
14+
li.append(name)
15+
li.append(dat)
16+
li.append(book_id)
17+
li.append(book_name)
18+
for line in li:
19+
file.write(str(line)+" ")
20+
file.write("\n")
21+
file.close()
22+
23+
def get_info(self):
24+
file=open("prg16.txt",'r')
25+
dat=date.today().strftime("%d/%m/%y")
26+
data=[]
27+
data=file.readlines()
28+
print("Details".center(50,"#"))
29+
print("\n{:15} {:10} {:15} {:10}".format("Student_Name","Date","Book_id","Book_name"))
30+
for line in data:
31+
value=line.split()
32+
if dat==value[1]:
33+
for i in value:
34+
print(i.ljust(15),end="")
35+
print("\n",end="")
36+
37+
ch=-1
38+
while(ch!=0):
39+
print("1 - Issue Book\n2 - Information today's issued book\n0 - Exit\n")
40+
ch=int(input("Enter choice :"))
41+
l=library()
42+
if(ch==1):
43+
l.issue_book()
44+
elif(ch==2):
45+
l.get_info()
46+
elif(ch==3):
47+
sys.Exit()

Diff for: prg16.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vishal 17/10/19 101 python
2+
joshi 15/10/19 102 java
3+
harsh 17/10/19 103 html
4+
vhjoshi 15/10/19 104 maths

Diff for: prg17.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class Bank:
2+
def __init__(self):
3+
self.acc_no=0
4+
self.bal=0
5+
print(self.bal)
6+
def addbank(self):
7+
self.acc_no=int(input("Enter the Bank Account Number :"))
8+
def deposit(self):
9+
amt=int(input("Enter Amount for Deposit :"))
10+
self.bal=self.bal+amt
11+
print("Amount Deposited!")
12+
def withdraw(self):
13+
amt=int(input("Enter Amount for Withdraw :"))
14+
self.bal=self.bal-amt
15+
print("\nAmount Withdrawed!")
16+
def transfer(self):
17+
print("transfer")
18+
def balance(self):
19+
print("Total Balance :",self.bal)
20+
21+
b=Bank()
22+
ch=-1;
23+
while(ch!=0):
24+
print("1 - Add Bank Accoount")
25+
print("2 - Deposit Money")
26+
print("3 - Withdraw Money")
27+
print("4 - transfer")
28+
print("5 - Show balance")
29+
print("0 - Exit")
30+
ch=int(input("Enter your Choice :"))
31+
if(ch==1):
32+
b.addbank()
33+
if(ch==2):
34+
b.deposit()
35+
if(ch==3):
36+
b.withdraw()
37+
if(ch==4):
38+
b.transfer()
39+
if(ch==5):
40+
b.balance()
41+
42+
43+

Diff for: prg18.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pylab as plt
2+
empid=[101,102,103,104,105]
3+
sal=[25000,35000,32000,10000,30000]
4+
plt.bar(empid,sal, label='Employee data')
5+
plt.xlabel('Employee ID')
6+
plt.ylabel('Employee Salary')
7+
plt.title('EMPLOYEE CHART')
8+
plt.legend()
9+
plt.show()

Diff for: prg19.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pandas as pd
2+
import matplotlib.pyplot as plt
3+
data = [['101', 'M', 34],
4+
['102', 'F', 40],
5+
['103', 'F', 37],
6+
['104', 'M', 30],
7+
['105', 'F', 44],
8+
['106', 'M', 36],
9+
['107', 'M', 32],
10+
['108', 'F', 26],
11+
['109', 'M', 32],
12+
['111', 'M', 36]]
13+
df = pd.DataFrame(data)
14+
df.hist()
15+
plt.title('Histogram Showing the number of Employees in Specific Age Groups')
16+
plt.show()

0 commit comments

Comments
 (0)