Skip to content

Commit fb34e4c

Browse files
Ch 3 Implement
1 parent e84ebad commit fb34e4c

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed

02_type.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
a = "1221212"
2+
b = int(a)
3+
t = type(b)
4+
5+
print(t)

03_input.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
a = int(input("Enter Number 1"))
2+
b = int(input("Enter Number 2"))
3+
4+
print("Number a is:", a)
5+
6+
print("Number b is:", b)
7+
8+
9+
10+
print("Sum is ",a+b)

Problem1.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
print('''
2+
Twinkle, twinkle, little star,
3+
How I wonder what you are!
4+
Up above the world so high,
5+
Like a diamond in the sky.
6+
7+
When the blazing sun is gone,
8+
When he nothing shines upon,
9+
Then you show your little light,
10+
Twinkle, twinkle, all the night.
11+
12+
Then the traveler in the dark
13+
Thanks you for your tiny spark;
14+
He could not see which way to go,
15+
If you did not twinkle so.
16+
17+
In the dark blue sky you keep,
18+
And often through my curtains peep,
19+
For you never shut your eye,
20+
Till the sun is in the sky.
21+
22+
As your bright and tiny spark
23+
Lights the traveler in the dark—
24+
Though I know not what you are,
25+
Twinkle, twinkle, little star.
26+
'''
27+
)

problem1.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
a =1
2+
b=3
3+
4+
print(a+b)

problem2.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pyttsx3
2+
engine = pyttsx3.init() # object creation
3+
4+
""" RATE"""
5+
rate = engine.getProperty('rate') # getting details of current speaking rate
6+
print (rate) #printing current voice rate
7+
engine.setProperty('rate', 125) # setting up new voice rate
8+
9+
10+
"""VOLUME"""
11+
volume = engine.getProperty('volume') #getting to know current volume level (min=0 and max=1)
12+
print (volume) #printing current volume level
13+
engine.setProperty('volume',1.0) # setting up volume level between 0 and 1
14+
15+
"""VOICE"""
16+
voices = engine.getProperty('voices') #getting details of current voice
17+
#engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male
18+
engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female
19+
20+
engine.say("Hello World!")
21+
engine.say('My current speaking rate is ' + str(rate))
22+
engine.runAndWait()
23+
engine.stop()
24+
25+
"""Saving Voice to a file"""
26+
# On linux make sure that 'espeak' and 'ffmpeg' are installed
27+
engine.save_to_file('Hello World', 'test.mp3')
28+
engine.runAndWait()

variable.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
a = 1
2+
3+
b = 2
4+
5+
6+
print(a + b)
7+
8+
c = True & True
9+
10+
print(c)

0 commit comments

Comments
 (0)