-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_variables.py
More file actions
53 lines (46 loc) · 2.12 KB
/
Copy path03_variables.py
File metadata and controls
53 lines (46 loc) · 2.12 KB
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
#======================================================================================
# VARIABLES
#--------------------------------------------------------------------------------------
# A variable is a name you create to store a value, so you can use it later in your code
# You can think of a variable as container that holds information
#======================================================================================
#--------------------------------------------------------------------------------------
# Creating a variable
#--------------------------------------------------------------------------------------
x = 20 # Here x is a variable and 20 is its value
print(x)
#--------------------------------------------------------------------------------------
# updating variable x's values to 30
#--------------------------------------------------------------------------------------
x = 30
print(x)
#--------------------------------------------------------------------------------------
# Creating New variable y with value as x + 10
#--------------------------------------------------------------------------------------
y = x + 10
print(y)
print()
# Use Cases
print("My Name is Alice")
print("Alice is learning Python")
print("Alice wants to become python expert\n")
print("My Name is Frank")
print("Frank is learning Python")
print("Frank wants to become python expert\n")
#--------------------------------------------------------------------------------------
# To Make code dynamic we use variables
# Variables make updates super easy(one change updates everything)
#--------------------------------------------------------------------------------------
name = "BOb"
language = "Python"
print("My Name is", name)
print(name, "is learning", language)
print(name, "wants to become", language, "expert\n")
#--------------------------------------------------------------------------------------
# Summary of Variables
#--------------------------------------------------------------------------------------
# Make program dynamic
# Name to store a value
# Stored in memory
# Reusable anytime
# Updatable anytime