There are following basic fundamentals of python as given below.
- Tokens
- Comments,Indentation and multi-lining
- Python types
- Operations and conversions
- Built-in functions
- Library functions
1.) Tokens :-
- Token can be defined as a reserved word, punctuation mark and each individual word in a statement .
- Token is the small unit in the given program.
There are some Tokens in python:-
- Identifiers
- keywords
- Literals
- Operators
1.) Identifiers :-
- Python identifier is a name used to identify a variable,Function,class,module, or other object.
- An identifier is used to identify the literals used in the programs.
Rules for creating identifiers :-
- Identifier name starts with alphabet (a-z, A-Z) or an underscore (_).
- Identifier Name can not start with digits (0-9).
- Keywords can not be used as Identifier.
- identifier Name must not contain any white space, or special characters (@,#,$,^,&,*,%,!,/).
- Identifier Name are case sensitive means Employee and employee is not the same.
- Examples of valid identifiers: a_1, a55, _a, ab etc.
- Examples of invalid Identifiers:
- 2a, a 9, a/2, a%2 etc.
Python Variables:-
- Variables is a name which is used to refer memory location.
- Variable is also used to hold value.
- In python , we need not to define DATA TYPE (int,float, string,char etc.) before variable name.Python language is automatically detect the variable type when it runs,
- In python, variable name can be a group of letters and digits.But they are not start with digits (1-9).
- Python language is case sensitive,so variable name 'Ram' can not be same as variable name ram.
Declaring Variable and Assigning values :-
- Python language does not declare variable name before using in program.
- We don't need to declare variable explicitly in python.when we assign any value in any variable at that time ,it is declared automatically.Means declaration and assignment of variable at a time.
- The eual (=) operator is used to assign value to a variable in python.
e.g.
(variable name = value)
a=5
b=10
name='Ram'
print (a )
print( b )
print (name)
Output :-
5
10
Ram
Python Data types :-
Python language is a dynamically typed language hence we need not to define the data type of the variable while declaring it.
- Python variable are built-in types.Means interpreter implicitly binds the value with its type.
Type () function :-
We can check the data type of the variable using this type() function in python program.
Example:-
a=15
b=7.5
name='Ram'
print(type(a))
print (type(b))
print(type(name))
output:-
<class 'int'>
<class 'int'>
<class 'str'>
Watch Lecture 4 Complete Video:-
Watch Lecture 4 Complete Video:-
0 comments:
Post a Comment