Skip to content

Commit 0613062

Browse files
committed
python
1 parent 11e3097 commit 0613062

15 files changed

+747
-0
lines changed

GetProjects.mp3

18.6 KB
Binary file not shown.

SchoolManagement.db

12 KB
Binary file not shown.

day53(operator overloading).py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#operator overloading
2+
class Vector:
3+
def __init__(self,i,j,k):
4+
self.i=i
5+
self.j=j
6+
self.k=k
7+
def __str__(self):
8+
return f"{self.i}i + {self.j}j + {self.k}k"
9+
def __add__(self,x):
10+
return Vector{ self.i+x.i,i + self.j+x.j,j + self.k+x.k,k }
11+
v1=Vector(3,5,6)
12+
print(v1)
13+
v2=Vector(3,5,6)
14+
print(v2)
15+
16+
print(v1+v2)
17+
print(type(v1+v2))

day54(Singleinherit).py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ek parent se child class
2+
class Animal:
3+
def __init__(self, name, species):
4+
self.name = name
5+
self.species = species
6+
7+
def make_sound(self):
8+
print("Sound made by the animal")
9+
10+
class Dog(Animal):
11+
def __init__(self, name, breed):
12+
Animal.__init__(self, name, species="Dog")
13+
self.breed = breed
14+
15+
def make_sound(self):
16+
print("Bark!")
17+
18+
d = Dog("Dog", "Doggerman")
19+
d.make_sound()
20+
21+
a = Animal("Dog", "Dog")
22+
a.make_sound()
23+
24+
# Quick Quiz: Implement a Cat class by using the animal class.
25+
# Add some methods specific to cat

day55(Multipleinherit).py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ek se jayda class mila ke ek class banaya jata h =multiple inheritance
2+
3+
class Employee:
4+
def __init__(self, name):
5+
self.name = name
6+
def show(self):
7+
print(f"the name is {self.name}")
8+
9+
10+
class Dancer:
11+
def __init__(self, dance):
12+
self.dance = dance
13+
def show(self):
14+
print(f"the dance is {self.dance}")
15+
16+
class EmployeeDancer(Dancer,Employee):
17+
def __init__(self, name,dance):
18+
self.dance = dance
19+
self.name = name
20+
21+
o= EmployeeDancer("Vishal","Kathak")
22+
print(o.name)
23+
print(o.dance)
24+
o.show()
25+
print(EmployeeDancer.mro()) #mro-Method Resolution Order
26+

day56(multilevelinherit).py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# grandfather-father-son
2+
class Animal:
3+
def __init__(self, name, species):
4+
self.name = name
5+
self.species = species
6+
7+
def show_details(self):
8+
print(f"Name: {self.name}")
9+
print(f"Species: {self.species}")
10+
11+
class Dog(Animal):
12+
def __init__(self, name, breed):
13+
Animal.__init__(self, name, species="Dog")
14+
self.breed = breed
15+
16+
def show_details(self):
17+
Animal.show_details(self)
18+
print(f"Breed: {self.breed}")
19+
20+
class GoldenRetriever(Dog):
21+
def __init__(self, name, color):
22+
Dog.__init__(self, name, breed="Golden Retriever")
23+
self.color = color
24+
25+
def show_details(self):
26+
Dog.show_details(self)
27+
print(f"Color: {self.color}")
28+
29+
o = Dog("tommy", "Black")
30+
o.show_details()
31+
print(GoldenRetriever.mro())
32+

day57(Hybrid,Hierarchical).py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#Hybrid inheritance
2+
class A:
3+
pass
4+
5+
class B(A):
6+
pass
7+
8+
class C(A):
9+
pass
10+
11+
class D(B,C):
12+
pass
13+
14+
#hierarchical inheritance
15+
class A:
16+
pass
17+
18+
class B(A):
19+
pass
20+
21+
class C(A):
22+
23+
pass
24+
25+
class D(B):
26+
pass

day58(time model).py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import time
2+
def usingWhile():
3+
i=0
4+
while i<50000:
5+
i=i+1
6+
print(i)
7+
8+
def usingFor():
9+
for i in range(50000):
10+
print(i)
11+
12+
init=time.time()
13+
usingWhile()
14+
t1=time.time()-init
15+
16+
init=time.time()
17+
usingFor()
18+
19+
print(time.time()-init) #return the time in seconds
20+
print(t1)
21+
22+
#time.sleep---
23+
24+
# print(4)
25+
# time.sleep(3)
26+
# print("this is printed after 3 seconds")
27+
28+
29+
#strftime method---
30+
31+
t = time.localtime()
32+
formatted_time = time.strftime("%Y-%m-%d %H:%M:%S", t)
33+
34+
print(formatted_time)
35+
# Output: 2022-11-08 08:45:33

day59.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# import win32com.client as wincom
2+
3+
# # you can insert gaps in the narration by adding sleep calls
4+
# import time
5+
6+
# speak = wincom.Dispatch("SAPI.SpVoice")
7+
8+
# text = "Python text-to-speech test. using win32com.client"
9+
# speak.Speak(text)
10+
11+
# # 3 second sleep
12+
# time.sleep(3)
13+
14+
# text = "This text is read after 3 seconds"
15+
# speak.Speak(text)
16+
import win32com.client
17+
speaker = win32com.client.Dispatch("SAPI.SpVoice")
18+
speaker.Speak("Jumpman Jumpman Jumpman Them boys up to something!")

ex-10(Shoutout).py

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## import libraries
2+
3+
from tkinter import *
4+
from gtts import gTTS
5+
from playsound import playsound
6+
7+
8+
9+
################### Initialized window####################
10+
11+
root = Tk()
12+
root.geometry('350x300')
13+
root.resizable(0,0)
14+
root.config(bg = 'ghost white')
15+
root.title('Vishalsiingh - TEXT_TO_SPEECH')
16+
17+
18+
##heading
19+
Label(root, text = 'TEXT-TO-SPEECH' , font='arial 20 bold' , bg ='white smoke').pack()
20+
Label(root, text ='Vishalsiingh' , font ='arial 15 bold', bg = 'white smoke').pack(side = BOTTOM)
21+
22+
23+
24+
25+
#label
26+
Label(root, text ='Enter Text', font ='arial 15 bold', bg ='white smoke').place(x=20,y=60)
27+
28+
29+
##text variable
30+
Msg = StringVar()
31+
32+
33+
#Entry
34+
entry_field = Entry(root,textvariable =Msg, width ='50')
35+
entry_field.place(x=20 , y=100)
36+
37+
38+
###################define function##############################
39+
40+
def Text_to_speech():
41+
Message = entry_field.get()
42+
speech = gTTS(text = Message)
43+
speech.save('vishal.mp3')
44+
playsound('vishal.mp3')
45+
46+
def Exit():
47+
root.destroy()
48+
49+
def Reset():
50+
Msg.set("")
51+
52+
#Button
53+
Button(root, text = "PLAY" , font = 'arial 15 bold', command = Text_to_speech, width =4).place(x=25, y=140)
54+
Button(root,text = 'EXIT',font = 'arial 15 bold' , command = Exit, bg = 'OrangeRed1').place(x=100,y=140)
55+
Button(root, text = 'RESET', font='arial 15 bold', command = Reset).place(x=175 , y =140)
56+
57+
58+
#infinite loop to run program
59+
root.mainloop()

0 commit comments

Comments
 (0)