Variables are like containers that stores data in them. Now the stores data they can be accessed using these variables. These variables are stored in RAM.
- A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- Variable names are case-sensitive
a = 10
print(a)
# print(A) #error - As a and A are differently treated(case-sensitive)
b = "Python"
print(b)
c = None
print(c)
d = true
print(d)
a1 = "first_name"
a2 = "second_name"
b1 = 12
b2 = 23
print(a1+a2) #valid
print(b1+b2) #valid
# print(a1+b1) #error -- since the datatypes of both are different
# How to get the type of data(which maybe stored in a variable)
print(type("name"))
a = 100
print(type(a))
Data are categoried into various types depending on it's nature and tha actions that can be performed with them. These are different types of values that a variable can store
Python has some built in data types
Category | Data Type | |
---|---|---|
Text Type | str |
|
Numeric Type | int , float , complex |
|
Sequence Types | list , tuple , range |
|
Mapping Type | dict |
|
Set Types | set , frozenset |
|
Boolean Types | bool |
|
Binary Type | bytes , bytearra , memoryview |
|
None Type | None |
|
In Python everything is
object
, any data type isobject
You do not need to rememeber the list
We will be exploring all of these afterwards