9/1/22

Introduction to Python Programming

 Python Notes Unit 1, Part 1

UNIT – 1(part 1)

    


   Introduction to Python Part 2

  Introduction to Python Part 3 


Introduction to Python

History and its Features

Basic Syntax

Understanding Python variables

Numeric data types

Using string data type and string operations

Basic Operators

Understanding coding blocks.

Defining list and list slicing,

Other Data Types- Tuples. List, Python Dictionary, Arrays, Associative Arrays/Hashes

 

Introduction to Python

1.     Python is a general-purpose high-level programming language was introduced by Guido Van Rossum, in 1991.

2.     Python is also dynamic and interpreted language.

3.     It uses new lines to complete a command, as opposed to other programming language. Python cannot use any semicolons and parenthesis.

4.     Python programmers are often known as Pythonists or Pythonistas.

5.     This language is easy and understandable for learners.

 

History of Python: -

    1.   In 1980s Python laid its foundation and its implementation was started in December 1989 by Guido Van Rossum at CWI in Netherland.

    2.   The code was published by Guido Van Rossum in February 1991 with labeled version 0.9.0 to alternate sources.

    3.   In the year 1994, Python 1.0 was released with its new and advance features like lambda, map, filter, and reduce.

    4.   After that Python 2.0 were published with some more features like list comprehensions, garbage collection systems etc.

    5.   On 3rd December 2008 Python 3.0 also know as “Py3k” was released.

 

Features of Python: -

 These are following features of python:-

1.   Simple and Easy to learn.

2.    High Level Programming Language

3.   Platform independent

4.   Portability

5.   Dynamically Typed

6.   Procedure oriented and object oriented                               

Simple and Easy to learn: -

                       i.         Python code looks like English words.

                     ii.         There is no use of semicolons and brackets, and the indentation of the code block.

                   iii.         We can tell what the code is supposed to do simply by looking at it.

High Level Programming Language: -

                     i.           Programmers don’t need to remember the system architecture, and not do they have to manage the memory.

                   ii.           High level programming approach makes it super programmer-friendly and is one of the key features of Python.

Platform Independent: -

                       i.         Python programs are platform independent.

                     ii.         Once we write a program, it can run on any platform without rewriting once again.

Portability: -

                       i.         Python is portable in the sense that the same code can be used on different machines.

                     ii.          Suppose we are writing a python program on Mac OS and if we want to run it on Windows and Linux later, we don’t have to make any changes in the program.

Procedure oriented and Object oriented: -

                       i.         A programming language is procedure-oriented if it focuses on functions.

                     ii.         A programming language is object-oriented if it focuses on design around data and objects, rather than functions and logic.

                   iii.         Python features is that it supports both procedure-oriented and object-oriented.

 

Basic Syntax: -

Syntax is one of the basic requirements that we must identify to code in any languages.

In Python, we use indentations (the action of indenting) to represent the block of the code.

Let’s understand basic syntax of Python Programming with the help of some line of codes: -

                                        print (‘id:’,1)

                                        print (‘name:’, ‘Diploma Student’)

                                        print (‘age:’, ‘18’)

Python programming language don’t use any terminator operator which means we don’t have to use any semicolon symbol or any bracket to terminate the code.

If we have to print something we can use below code: -

               print (“Diploma Student..!!”)

 

Here is one single statement which is used to print “Diploma Student..!!

 

 

Python Variables: -

    1.   Python variable is containers which store values.

    2.   In python there is no need to define type of a variable hence python is called dynamically-typed language.

A=25         #type of a is int

B=25.4      #type of b is float

C= ‘hello’ #type of c is str

    3.   A variable is created at that the moment when we first assign a value to it.

    4.   A python variable is a name given to a memory location.

    5.   Python variable is the basic unit of storage in a program.

    6.   Type of variable can check using built in function type()

Name= ‘Diploma student’

Print(type(name))     #type will be reported as str

    7.   Simple variable assignment.

var = “sem6”

print (Var).

Rules of creating variables is python: -

(a)         A variable name must start with a letter (A-Z or a-z) or underscore character.

(b)         A variable name cannot start with a number (1abc is not allowed).

(c)         A variable name can only contain alpha-numeric characters and underscores (A-Z, a-z, 0-9, and _)

(d)         Variables name are case sensitive ( Example- name, Name and NAME are three different variables.).

In python, there are mainly two types of variables: -

1.   Local variables

2.   Global variables

 

Next Part is coming soon..!! keep study and keep growing

Thank you..!!

No comments:

Post a Comment

Please do not enter any spam link in the comment box and use English and Hindi language for comment.

Latest Update

Key Components of XML

Popular Posts