2. Python_Variables
2. Python_Variables
In [3]: Print("welcome to the world of coding") ##### P is capital so wont't work, Keywork should always start with small letter
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[3], line 1
----> 1 Print("welcome to the world of coding")
In [ ]: #### Notes
#1. Python is case sensitive
#2. Set of predefined keywords
#Variables
#1. Variables are placeholders, store it and it will be useful for future
#2. Variables are case-sensitive
#3. As the name suggests variables can vary (we can overwrite)
#4. Only one special Character is allowed i.e _(underscore), space and other special characters are not allowed
#5. The variable name should be a single-word
#6. It can end with a number but cannot start with a number
#7. Don't use keywords as variable name
#8. We can assign value to a variable by using =
#9. Variables Can be Overwritten or changed
In [1]: a = 5
print(a)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[2], line 1
----> 1 print(A)
In [6]: a= 3
b= 5
c=(a+b)
In [7]: print(c)
In [9]: a=4
b=2
c=a+b
In [10]: print(c)
In [ ]: #Naming of variables
totalstudents = 75 #### acceptable
total_student = 75 # acceptable
ts = 75 #### acceptable
TotalStudents = 75 #### acceptable
total@students = 75 #### not acceptable coz. no other special character other than _
_total_students = 75 #### acceptable
total_students7 = 75 #### acceptable coz. variable can end with number
7total_students = 75 #### not acceptable coz it starts with number
In [1]: total_students=75
type(total_students)
Out[1]: int
In [1]: dhoni_player="captain"
type(dhoni_player)
Out[1]: str
In [5]: print(Dhoni)
In [7]: print(Dhoni7)
Best Cricketer
KSR Datavizon
In [4]: type(institute)
Out[4]: str
In [5]: a="sunil"
b='sunil'
print(a)
sunil
In [6]: print(b)
sunil
In [7]: type(a)
Out[7]: str
In [8]: type(b)
Out[8]: str
In [9]: print(KSR)
In [10]: a = 70
In [11]: print(a)
70
In [12]: a = 80
80