Python

 Basic of Python Programming language

let's get started with python:

Introduction of python

Python is a high level programming language which is used for solving real life problem in various field. It is used in web designing and development, research area and many more.

features of python:

  1. Free and open source.
  2. Simple and easy to understand.
  3. Dynamically type programming language.
  4. Interpreted language
  5. Platform independent language.
Classification of Data type in Python:
There are two type of data type in python such as Immutable and mutable.
  1. Immutable: Variables whose values cannot be changed after they are created and assigned. If the value of  immutable variable is updated then old variable is destroyed and new variable is created with same name in memory.                                           They are Integers, Float, Boolean, Complex, Strings, Tuples, Sets. 
  2. Mutable: Variables whose values can be changed after they are created and assigned. They are Lists and Dictionary.
Operators in python:
An operators are used to perform mathematical or logical operation on values. The values on which operators work is called operands
for example:
     add = 10 + 20
where, 
           add is variable name
            = is assignment operator
            10 and 20 are operands
            + sign is operator    
Type of operators:
  1. Arithmetic Operators: Addition(+), Subtraction(-), Multiplication(*), Division(/), Modulus(%), Floor Division(//), Exponent(//).
  2. Relational Operators: Equals to(==), Not equal to(!=), Greater than(>), Less than(<), Greater than or equal to(>=), Less than or equal to(<=).
  3. Assignment operators: =,+=, -=, *=, /=, %=, //=, **=.
  4. Logical Operators: and, or, not.
  5. Identity Operators: is, is not.
  6. Membership Operator: in, not in.
precedence of operators in python:

Order of Precedence

Operators

Description

1

**

Exponentiation(raise to the power)

2

~, +, -

Complement, unary plus and unary minus

3

*, /, //, %

Multiply, division, modulo and floor division

4

+,-

Addition and subtraction

5

<=, <, >, >=

Relational operators

6

==, !=

Equality operators

7

=,%=, /=, //=, -=, +=, *=, **=

Assignment operators

8

is, is not

Identity operators

9

in , not in

Membership operators

10

not, or, and

Logical operators

    
Input and output in python:
Syntax for input()  in python
        input([prompt])
here, prompt is a  string we want to display on the screen.
for example,
        name=input("enter your name:")
        enter your name: diya

Syntax for output in python:
        print() is used to output data to output device.
 for example,
        print("hello")    output- hello

Type conversion:
There are two type of type conversion: explicit type casting and implicit type casting
  1. explicit type casting: syntax- (new data type) (Expression)  for example: if  num=20.6 then to convert into integer we need explicit type conversion as follows int(num).
  2. implicit type casting: It is also called coercion, happens when data type conversion is done automatically by python.


next we will solve problems based on these topics. see you soon......



        


Comments