Variables and Data types in Python
What is variables ?
A variable is a name given to a memory location in a program.
Example : –
variable is use to contain a value.
What is keyword ?
Predefine or reversed words in programmming languages are called keywords.
ex – print(), input() etc all are keywords.
What is identifier ?
An identifier is nothing but a name assigned to an element in a program. Example, name of a variable, function, etc. Identifiers are the user-defined names . As the name says, identifiers are used to identify a particular element in a program.
Data Types in python
Data type identify the type of variable. Data type is an important concept. Variables can store data of different types, and different types can do different things.
Basic Data Types in Python :
- Integer – a number without decimals ( 1, 55, 234 )
- Float – a number with decimals values ( 2.4, 5.8 )
- Strings – A set of characters called strings ( this is a string ) and strings are written inside the double or single quotes
- Booleans :- True or False
- None :- Doesn’t not contain any value.
Python is a fantastic programming language that automatically identifies the type of variables
Example :-
a = 71 ( identifies as <int>) means it is an integer value
b = 2.5 (identifies as <float> ) means it is a floating number.
c = “string” ( identifies as <str> ) means it is a string value
Type casting using Type() function.
Type() function is use to find the data type of a variable in python
example :-
Output : –
Note : – Every thing in python is an object.
Comments
Post a Comment