-
Notifications
You must be signed in to change notification settings - Fork 44
/
Chapter_3rd.py
73 lines (54 loc) · 1.21 KB
/
Chapter_3rd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Example 1
print ("Hello World!")
# Example 2
if 5 > 2:
print("Five is greater than two!")
# Example 3
# This will give an error due to incorrect indentation
if 5 > 2:
print("Five is greater than two!") # Fix: add 1 tab in the beginning of line.
# Example 4
#This is a comment
print("Hello, World!")
# Example 5
print("Hello, World!") #This is a comment
# Example 7 - comment with short-key - select lines below and press Ctrl+1 buttons.
# This is a comment
# written in
# more than just one line
print("Hello, World!")
# Example 8
# Computer the value of a block of stock
shares= 150
price= 3 + 5.0/8.0
value= shares * price
print("value",value)
# Example 9
# Total value of a portfolio made up of two blocks of stock
portfolio = 0
portfolio += 150 * 2 + 1/4.0
portfolio += 75 * 1 + 7/8.0
print("portfolio", portfolio)
# Example 10
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
# Output
# Orange
# Banana
# Cherry
# Example 11
x = y = z = "Orange"
print(x)
print(y)
print(z)
# Output
# Orange
# Orange
# Orange
# Example 12
first_number = 4
second_number = 6
summation = first_number + second_number
# Output will be 10