-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson2.py
More file actions
94 lines (71 loc) · 1.28 KB
/
lesson2.py
File metadata and controls
94 lines (71 loc) · 1.28 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This lesson covers python Variables
# Python Identifiers
number = 10
print(number)
a = 'Senior Developer'
print(a)
_a = "Captain"
print(_a)
x_y = 'Numerical Python'
print(x_y)
print("john")
print(type("john"))
# Object Identity
a = 50
b = a
print(id(a))
print(id(b))
# Reasigne variable a
a = 500
print(id(a))
# Variable Names
name = "Andela LC"
age = 12
worth = 85.55
print(name)
print(age)
print(worth)
# Multiple Assignment
a=b=c=100
print(a)
print(b)
print(c)
d,e,f = 20,30,40
print(d)
print(e)
print(f)
# Local Variables
# Declaring a function
def product():
# Declaring local variables. They have scope only within the function
j = 30
k = 40
l = j*k
print('The product is ',l)
# Function Calling
product()
# Accesing variable out of function will bring an error at our console
# print(l)
# GLOBAL VARIABLES
# Declare a variable and initialize it
m = 200
# Global Variable function
def myglobalvariable():
# Printing the global variable
global m
print(m)
# We try to modify the global variable
m = 'Welcome to Nepapa Technologies'
print(m)
myglobalvariable()
print(m)
# Printing Multiple variables
print("---Print Multiple Variables---")
p='Justine'
q=20
r=3.0
print(p,q,r)
# Print Variable Types
print(type(p))
print(type(q))
print(type(r))