Basic fundamentals of Python part 1

By
There are following basic fundamentals of python as given below.
  1. Tokens
  2. Comments,Indentation and multi-lining
  3. Python types
  4. Operations and conversions
  5. Built-in functions
  6. 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:-
  1. Identifiers
  2. keywords
  3. Literals
  4. 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 :-
  1. Identifier name starts with alphabet (a-z, A-Z) or an underscore (_).
  2. Identifier Name can not start with digits (0-9).
  3. Keywords can not be used as Identifier.
  4. identifier Name must not contain any white space, or special characters (@,#,$,^,&,*,%,!,/).
  5. Identifier Name are case sensitive means Employee and employee is not the same.
  6. Examples of valid identifiers: a_1, a55, _a, ab etc.
  7. Examples of invalid Identifiers:
  8. 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:-

0 comments:

Post a comment

Powered by Blogger.