Basic fundamentals of Python part 2

By
Python keywords :-
  • Python has 33 keywords that are given below.
  • All keyword in lowercase except(False,None&True)

Note ->
  • keyword is not used as identifier name in the application.
Comments,Indentation and Multi-lining:-
  • Comments begin with #
Eg. #sum of two numbers
          p=a+b
           OR
          q=a+b  #sum of two numbers
  • Multi-line comments should be written in a pair of ''' or """
Eg.
''' Name = Ram
  Age = 30
  Education= B.Tech
  Occupation=Student'''
              OR

Eg.
"""Name = sita
    Age = 20
    Education= B.Tech
    Occupation=Student"""

  • In python,Indentation is more important. You have to use it very carefully.Don't use it casually.Following code will be reported as error.
Eg.
a=10
b=5
  c=a+b

  • Following python code will be correct manner as given below:-
Eg.
a=5
b=10
c=a+b

  • We can use \ (backslash) in python codes ,when we want to write multi-line with each line except the last ending with a \  .
Total_marks = Physics+Math+English+\
              History+Economy +\
              Chemistry+Hindi+Civics+\
              biology

  • If we are using following brackets [ ] , { }and ( ). we don't need \ (backslash) as shown below.
Eg

Total_marks =[Physics+Math+English+ 
               History+Economy + 
               Chemistry+Hindi+Civics+ 
               biology]


  • In python programming ,there is no need to define type of a variable .
Eg.
a=5
b=20
c=a=b
print(c)


  • Simple Variable declaration and assignment in python language.
Eg.
a=12
b=17
name='Ram'

  • Multiple Variable assignment:- We can use multiple variable assignment in python.We can use ; as statement separation.
Eg.
a=10;b=30;c=40;name='Ram'
              OR
a,b,c,name=10,30,40,'Ram'
#If more variable has same value:
p=q=r=20
Python Types:-
There are some built-in types of python as given below:-

  • Basic Types:- int,float,complex,bool,bytes,string .
  • Container types:- list,tuple,set,dict
  • User-defined :- class
  • Numbers:-
int -> 156(decimal),0432 (octal),0x4A3(hexadecimal)  
float -> 314.1528(decimal),3.141528e2 (octal), 3.141528E2(hexadecimal) 
complex -> 5+4j , 3+10j # contains real and imaginary part

Watch Lecture 5 Complete Video:-

0 comments:

Post a Comment

Powered by Blogger.