In the previous post, we initialized variable with only numerical values.
Can we store a character, string and floating values in variable?
Yes we can store all kind of values in the variable.
Let's have a look how we can initialize all types of values.
How to initialize a character in python?
A value within quotes can be stored as type character.
variable1 = 'a' # character a is stored in variable1
variable2 = '1' # 1 is stored as a character in variable2
variable3 = '&' # special character is stored as character in variable3
How to initialize a string in python?
A word or a sentence within quotes can be stored as a string.
var1 = 'codicious'
var2 = 'this is how a string value is stored'
How to initialize a float in python?
float_1 = 15.256
float_2 = 365.029
How to initialize a variable with Boolean value in python?
There are two values in Boolean, i.e. True and False.
boolean_1 = True
boolean_2 = False