JOBS ESTATE FREE EMAIL ALERTS

 

  • Always Should maintain indentation and use collan(:) for if ,while condition.

//Other languages like C/Java

if(condition){

}

While(Condition){

}

#Python

if(condition) :

  statement 1

  statement 2

else(condition):

  statement  1

 

While(condition):

  Statement 1

  Statement 2

  • Comments:

#This is a comment

x = 10 # this is also a comment(Can write after statement treated as comment)

y = 20.5

z = 6+8J

  • Continuation operator:(use Back slash \):-

Inorder to divide single statement into multi line statements we use Backslash \.Therefore python thinks next line also continuation (same) line no need indentation.

X = “hello my channel name is ” \

“Raviteja”

  • Suite:

Other Languages we call it as Block(Set of statements,also we use curly braces { }),In python called as Suite (set of statements with indentation and Collan(:) only,we don’t use curly braces here).

if(condition) :

    statement 1

   statement 2

else(condition):

   statement  1

  • Semicollan(;):

It is not Mandatory semicollan to end of the statement.(x=10; or x=10)

It is Mandatory only set of continuous statements in same line inorder to separate the statements.(x=10;y=20;z=30; and cannot write x=10 y=20 z=30).

 

  • Variable Assignment and its Data type:

i)It Can assign a value to variable name without using data type,At run time it will decide its data type accordingly given by user so it called as Dynamic typed Languages(which doesn’t have keywords/data types,example-PHP,Javascript).

a = 10 # integer

b = 1.25 # float

c = 1+6J # complex

 

# multiple assignment with same value

a = b = c = 10

 

# multiple assignment with different value

a,b,c=1,2,3

 

ii)Expressions not allowed while assign to a variable name.

x = 10

y = (x = x+1)  # This is not allowed in python.

 

iii)Swapping of two variables is very easy in python compare to other Languages.

# a,b values swapping in C/Java

        temp = a;

        a = b;

        b = temp;

 # a,b values swapping in python

      (a,b) = (b,a)

iv)Support multiple assignment of a variable

# multiple assignment with same value

         a = b = c = 10

        # multiple assignment with different value

                    a,b,c=1,2,3

 

  • Identifiers:
  1. i) Identifier name can starts with _(underscore) and Alphanumeric(a,b,c,1,2,3…)
  2. ii) keywords cannot used as identifiers like other languages.

 

  • Memory Management:-

python supports automatic memory management

  1. i) No Need to declare the variables(starting of the program like java/C).
  2. ii) No Need to declare the Datatypes.

iii) No Burden to the programmer for memory management.

iv)Variables can be recycled(using garbage collection-means which are not using                        variables).

  1. v) Use “del” keyword to deallocate memory manually.

 

  • Python Objects:-

 In Python Everything treated as Object.If we store any value in a variable treated as object because it is Object oriented programming language.

3 Characteristics: Every object will have 3 characteristics

  1. i) Identifier
  2. ii) Type

iii) Value

© Copyright 2020 Jobs Estate All Rights Reserved