Variable basically ek container hota hai jisme ap data value store krte ho .
example
a = "hello"
b = 3
c = 3.4
To idhar ap dekh skte hai a, b, c ye teeno variable hai , a mai hmne hello naam ki string ko store kiya hai , b mai hmne 3 ko store kiya hai aur c m hamne 3.4 ko store kiya hai
ap ise aise bhi samjh skte ho ki (a) ek box h jyisme hmne hello ko daal diya hai , i hope ki apko variable bahut acche se clear ho gya hoga.
Waise mai apko bta du ki baki programming language jaise java waha hme variable ko declare krna padta hai mtlb hme batana padta hai ki ye variable kis type ka hai jaise int , float , string, char etc.
lekin python mai hme yaha batana nhi padta ki ye kis type ka hai.
Int , float , string , char ka use kaha hota h let's see
inka use in value ko store krne mai hota hai.
Jaise ki maine bataya ki python mai ham data type mention nhi krte hai pr agar apko janna hai ki ye variable kis type ka hai to ap jan skte hai by using "type" keyword let see an example
Input
a = "Hello"
print(type(a))
output
<class 'str'>
to ye bata raha hai ki a string type ka hai, ap string variable ko single inverted comma ya double inverted comma dono me likh skte ho
"Python ek case sensitive language hai jiska mtlb ye hai ki ram aur Ram do differnent word hai"
Rules for writing variable name
variable ka naam chota bhi ho skta hai aur bada bhi jaise ( a, name ) , Rules for python variable..
- variable start hona chahiye letter se ya fir underscore se ( _ )
- variable kisi number se start nhi ho skta
- variable m kewal alpha- numeric character aur underscore ho skte hai
a =2
number = 2
_var = 2
var1 =2
NUMBER =2
var_1 =2
"python mai character data type nhi hota , python mai character data type ko string of length one mana jata hai"
python mai ap value aise bhi assign kr skte ho
a, b, c =1,2,3
iska mtlb ye hua ki a mai 1 jayega b mai 2 jayenga aur c mai 3 jayega
Comments
Post a Comment