Skip to content

Commit 0e97426

Browse files
lesson345
1 parent 0e3a240 commit 0e97426

File tree

3 files changed

+110
-5
lines changed

3 files changed

+110
-5
lines changed

lesson3.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
z = "green"
55

66
x = y = z = 20
7-
print("x",x)
8-
print("y",y)
9-
print("z",z)
7+
# print("x",x)
8+
# print("y",y)
9+
# print("z",z)
1010
x = 5
1111
y = 15
1212

13-
print("x",x)
14-
print("y",y)
13+
# print("x",x)
14+
# print("y",y)
1515

1616
# identifier
1717

@@ -37,4 +37,35 @@
3737
# Tuple
3838
# dictionary
3939

40+
# arithmetic operators
4041

42+
x = 1.1
43+
y = 2.2
44+
# print(x+y)
45+
46+
a = 5
47+
b = 6
48+
# print(a*b)
49+
50+
c = 3.9
51+
d = 3.3
52+
# print(c/d)
53+
# print(c%d)
54+
55+
# complex (use j/J) real part + imginary part
56+
a = complex(1,2)
57+
# print(a)
58+
# print(a.real)
59+
# print(a.imag)
60+
61+
# convert using float() int() and complex()
62+
x = 100
63+
y = 2.8
64+
z = 1j
65+
66+
# convert integer to float
67+
print(float(x))
68+
# convert float to integer
69+
print(int(y))
70+
# convert int to complex
71+
print(complex(x))

lesson4.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# control structures
2+
a = 400
3+
b = 300
4+
# if a < b :
5+
# # print('a less than b')
6+
# else :
7+
# # print('b greater than a')
8+
9+
10+
c = 500
11+
d = 500
12+
# if c < d:
13+
# # print('c less than d')
14+
# elif c > d:
15+
# # print('c greater than d')
16+
# else :
17+
# # print('c and d value are equal')
18+
19+
# largest Number
20+
a = 100
21+
b = 200
22+
c = 300
23+
d = 400
24+
25+
if (a > b) and (a > c) and (a > d) :
26+
largestNumber = a
27+
print('Largest Number is : ', largestNumber)
28+
elif (b > a ) and ( b > c) and (b > d) :
29+
largestNumber = b
30+
print('largest Number is : ', b)
31+
elif (c > a) and (c > b) and (c > d):
32+
largestNumber = c
33+
print('largest Number is : ', largestNumber)
34+
else :
35+
largestNumber = d
36+
print('largest Number is : ', largestNumber)
37+

lesson5.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# calculator program
2+
# Lesson 5
3+
4+
print("Press + for Add")
5+
print("Press - for Subtract")
6+
print("Press * for Multiply")
7+
print("Press / for Divide")
8+
9+
userInput = input('please enter operator for Add or Subtract or Multiply or Divide')
10+
# print(userInput)
11+
print('you entered : ', userInput)
12+
13+
firstNumber = int(input('Enter Your First Number'))
14+
print('your first number is : ', firstNumber)
15+
16+
secondNumber = int(input('Enter Your Second Number'))
17+
print('your second number is : ', secondNumber)
18+
19+
if userInput == '+' :
20+
result = firstNumber + secondNumber
21+
print('result is :', result)
22+
elif userInput == '-' :
23+
result = firstNumber * secondNumber
24+
print('result is :', result)
25+
elif userInput == '*' :
26+
result = firstNumber * secondNumber
27+
print('result is :', result)
28+
elif userInput == '/' :
29+
result = firstNumber / secondNumber
30+
print('result is :', result)
31+
else :
32+
print('your input {} is invalid ! Please try again later!'.format(userInput) )
33+
exit()
34+
35+
36+
37+

0 commit comments

Comments
 (0)