-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython_variables.py
78 lines (64 loc) · 1.54 KB
/
python_variables.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
76
77
78
# -*- coding: utf-8 -*-
"""python variables.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/15O2wQ2V_ZTvkR9p39As5XxJGjxABE9FY
"""
a = 100
b = a
print(id(a))
print(id(b))
print(a)
print(a)
# Reassigned variable a
a = 800
print(id(a))
print(a)
name = "OOPCourse"
Myage=Herage= 45 # Assigning single value to multiple variables
a=b=c=90
a=b=c=4,5,6
a,b,c=4,5,6 # Assigning multiple values to multiple variables:
print(name)
print(Myage,Herage)
print(a,b,c)
name = "Test1"
Name = "Test2"
naMe = "Test3"
NAME = "Test4"
n_a_m_e = "Test5"
_name = "Test6"
name_ = "Test7"
_name_ = "Test8"
na80me = "Test9"
print(name,Name,naMe,NAME) # Print multiple values
print(name,Name,naMe,NAME,n_a_m_e, NAME, n_a_m_e, _name, name_,_name, na80me)
# Declaring a function
def Myadd():
# Defining local variables. They has scope only within a function
m = 40
n = 40
p = m + n
print("The sum is:", p)
# Calling a function
Myadd()
# Accessing local variable outside the function. Gives an error
print('m')
# Declare a variable and initialize it
x = 200
# Global variable in function
def mFunction():
# printing a global variable
global x
print(x)
# modifying a global variable
x = 'Welcome To OOP'
print(x)
mFunction()
print(x)
del x
print('x')
c = 50000000000000000000000000000000000000000000
c = c + 1
print(type(c))
print (c)