-
Notifications
You must be signed in to change notification settings - Fork 0
/
Variables and Data Types-200.py
75 lines (54 loc) · 1.12 KB
/
Variables and Data Types-200.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
74
75
## 1. Saving Values ##
result=(42-11)*22
print(result)
## 2. Variables ##
a_value=15
a_result=(25-7)*17
print(a_value)
print(a_result+12)
print(a_value+a_result)
## 3. Variable Names ##
# INITIAL CODE
old_income = 34000
new_income = 40000
## 4. Updating Variables ##
income = 34000
print(income)
print(income+6000)
income+=6000
print (income)
## 5. Syntax Shortcuts ##
variable_1=20
variable_2=20
variable_2+=10
variable_1*=4
print(variable_1)
print(variable_2)
## 6. Integers and Floats ##
variable_1=10
variable_2=2.5
variable_1+=6.5
variable_2*=2
print(variable_1)
print(variable_2)
## 7. Conversion Between Types ##
variable_a=13.9
variable_b=2.8
variable_a=(round(variable_a))
variable_b=(int(variable_b))
print(variable_a)
print(variable_b)
## 8. Strings ##
app_name='Pandora - Music & Radio'
average_rating="4.0"
total_ratings="1724546"
price="free"
print(app_name)
## 9. Escaping Special Characters ##
motto="Facebook's new motto is \"move fast with stable infra.\""
print(motto)
## 10. String Operations ##
Facebook="Facebook's rating is "
fb_rating=float(3.5)
fb_rating_str=str(fb_rating)
print(Facebook+ fb_rating_str)