Variables
variable is a container to store python data .create once use multiple times (re-use)
syntax: variablename = python data (= assignment operator)
ex: sam=10
variable and thier values stores in a memory called “RAM”
# create a variable assign value then (run) checks the python engine any errors or not then store in a memory
#variable name is a temporary name thier address is a permnent name
#case1: same variable name different value python engine consider latest value
ex: sam=10
sam=20
o/p:20
#case2: Diffferent variable names with same value store in same memory location.ex: sam=10
if variable type is greter than the type range every time stores in different memory ex a=300 b=300 each a and b stores in diferrent location beaacuase a is a int datatype .range 0 to 255 so 290 exceeded int range.
Get Samanvitha’s stories in your inbox
Join Medium for free to get updates from this writer.
nvitha=10
#case3: to check the location of a variable we use (id(variablename/value of a variable))
ex: sam=10
id(sam) or id(10)
#case4: different variable names different values stores in different location
#rule1:variable name shouldnot include other special symbols & spaces
ex:sam_,j_sam,
#rule2: case sensitive upper and lower case letters different
ex:Sam & sam are different
#rule3:it should contains alphabets ,numbers&underscore
ex:sam19,j_samQQ2
#rule4: variable names doesnot starts with numbers.
ex:9sam wrong




