File tree Expand file tree Collapse file tree 4 files changed +112
-5
lines changed Expand file tree Collapse file tree 4 files changed +112
-5
lines changed Original file line number Diff line number Diff line change
1
+ > Learning Python Programming . . .
2
+
1
3
> Learning Python Programming Language
Original file line number Diff line number Diff line change 4
4
z = "green"
5
5
6
6
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)
10
10
x = 5
11
11
y = 15
12
12
13
- print ("x" ,x )
14
- print ("y" ,y )
13
+ # print("x",x)
14
+ # print("y",y)
15
15
16
16
# identifier
17
17
37
37
# Tuple
38
38
# dictionary
39
39
40
+ # arithmetic operators
40
41
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 ))
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments