-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path4-PythonVariables.py
75 lines (64 loc) · 1.42 KB
/
4-PythonVariables.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
#Variables are containers for storing data values.
'''
Python has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
'''
#Variable Assignment
n = 300
id(n)
print(n)
#Example
m = n
print("Value of m ",m)
print("id of m ",id(m))
print("Value of n ",n)
print("id of n ",id(n))
m=400
print("Value of m ",m)
print("id of m ",id(m))
print("Value of n ",n)
print("id of n ",id(n))
n = "Hello"
print("Value of m ",m)
print("id of m ",id(m))
print("Value of n ",n)
print("id of n ",id(n))
#TYPE of Variable
a = 2
type(a)
#Same id to these objects
n = 10
m = n
print("n = :",id(n))
print("m = :",id(m))
'''
Camel case nOfStudent = "Hamza"
Pascal case NOfStudent = "Subhan"
Snake case name_of_student = "Zeeshan"
'''
#Types of Variable data
#int
a = 10
b = -10
#float
a = 10.1
b = -10.1
#string
name = " Farooq "
#bool
a = True
#----------------------------------------------------------------
#using Print()
name = "Hashim"
age = 23
print('Age is ',age)
print('name is '+name)
#-----------------------------------------------------------------
#F-Strings (Formatted String Literals)
print(f'Age is {age} and Name is {name}')
#-----------------------------------------------------------------
#str.format() Method
print('Name : {} Age : {}'.format(name,age))
#-----------------------------------------------------------------
#Using % Formatting:
print('Age is %d and Name is %s'%(age,name))