You are on page 1of 50

Introduction to python:

 History of Python

 Version History of Python

 Why you should learn Python?

 Features of Python

 Amazing facts.

 Where Python can be used?

 Installation, IDLE, VS code

 Run your first python script

 Learning Path
History of python:
 History of Python

 Python was conceived in the late 1980. by Guido van


Rossum at Centrum Wiskunde & Informatica in the
Netherlands as a Successor of the ABC language. 

 Guido Van Rossum: He has been invariably worked as


developer, until 12 July 2018. the lead

 In Jan 2019, active Python core developers elected a five


member council to lead the project.
History of python:
 In 1991 Internet (1st website developed)

 In 1971 1st IC(Integrated circuit) made so comp side


decreased dramatically.

 C/C++ made according to the requirement in the 1971.

(ABC)

 Keywords -> capital letters

 No library Concept (Language was not extensible).

 Appropriate software should be in your computer to


accomplish the task.

 1989 December - python build started


History of python:
 Ameeba/Hydra (0S) + Script to create folder, rename
and place something in it.

 Python was created in 2 weeks (X-mas holiday).

 He worked at Google, Dropbox {worked till 2018).

 5 members team now looking for the development of


python.
Guido van Rossum:
Version History:
 Python 1.0 1994

 Python 2.0 2000

 Python 3.0 2008

 Latest version

 Python 3.10.6 2 Aug 2022

 python 2.0 V/S 3.0 (No backward compatibility).

 coding in python should be fun for anyone.

 Logo was designed by his brother.

  
Name->Python:

Python developers aim for it to


be fun to use.
The Name “Python” is a
tribute to the British comedy
group “Monty Python”.
Why you should learn Python:
 Huge community support

 Future is with AI

 Easy to learn and implement

 General purpose programming language

 AI introduced in mid 60's but computers were slow & less


storage Capacity.

 Intelligence → Example: child-Fire, bicycle/bike riding.

 Learning from own experiences is called Intelligence.

 Why practice is important? Robot step example


Why you should learn Python:
 The more data the more accurate AI System.

 Storage of data/computation power to process huge data

 A youtube data center, facebook, Amazon, netflix,


Google.

 A lot of code is already developed of AI in python.

 (ML)Recommendation system is everywhere -> content


based and Callborative filtering.
Features of Python:
 Highly Extensible

 Simple and straightforward syntax

 Multi paradigm programming language

 Emphasis on code readability

 Dynamic Typing

 Automatic memory management

 Dynamic Binding
Features:
 Highly Extensible-> can add more library.

 Simple and straightforward syntax-> There should be a only


way.

 Multi paradigm programming language-> oops, functional,


Structured, procedure oriented etc.

 Emphasis on code readability -> { int } code redability.

 Dynamic Typing -> Type can be changed at runtime.

 Automatic memory management-> New, Delete, malloc


memory release is the job of programmer in C/C++.

 Dynamic Binding -> function, call is known at run time!


which function will be called)
Features of Python:
 Precise coding

 For time critical operations , Python can use modules written in C


Language-> most of the decision are taken at runtime So python is slow.
In case of Particular activity should be fast in a project-> Can use c
language.

 Indentation base block of code-> { } in c/c++/ Java but here in Python


indentation is used

 Large library

 Platform independent

  
Amazing Facts of Python:
 Ranked # 1 (TIOBE )

 Highest rise in rating 2007,2010, 2018,2020

 It reduces app development time by 1/6

 Large organizations that uses Python are

Google, Netflix , Dropbox, Youtube , Instagram , CERN ,


Microsoft, NASA , Amazon, Facebook, Mozilla , etc.

 Youtube(made in python), Instagram(made in Django),


CERN- Tim burmer's Lee { 1st website made here}
Where Python can be used?:
 Developing websites

 Task automation

 Data Analysis

 Data visualization

 AI , ML , IOT

 Developmy desktop applications

 Python can also be used in developing mobile


applications, client side of AJAX based applications.
How to develop applications using C/C+
+?:
How to develop applications using
Python?:
Installation , IDLE , VS -Code:
 Download and install Python from
https://www.pythcn.org / downloads

 IDLE : Integrated Development and learning


Environment.

 VS -code : code -Editor


Run your first Program:
 First.py

print ( " Enter two numbers" )

a= int ( input () )

b= int ( input () )

c = a+ b

print ( “sum is" , c)


Learning Path:
Agenda:
 Comments

 Data

 Variables

 Dynamic Type

 Type()

 Data Types

 Memory Management

 print()

 Special characters
Comments:
 Single line comment ….. # Text

 Multi line comment

“““

……..

……..

……..

“””
Data:
 Prog is made- to process the data

 ATM → pin number / Amount is data

 Railway reservation -> booking Date, source/destination


station, no. of passengers etc.

 Khana Khazana(Recipie Book) [procedure (Program) &


Ingredients(Data)]
Data:
 Data is any piece of information which is used by the
program to accomplish a task.

 Examples of tasks

→ Find sum of two numbers

→ check whether a given number is even or odd

→ find LCM of two numbers

All the above tasks can be done only by using some data.
Variety of Data:
 Integers

age of a person 25

ATM PIN 0007

Number of students 250

 Real

price of a book 450.80

body weight 68.5

 Strings

city name “Raipur"

person name “Ajay”

book title “Python bible”


Data:
Variety of Data

 1) Operations on data

 2) Storage / Memory size

 3) Representation in memory: 1. Fixed point 1. Floating


point

  >>> string prompt

  >>> a [name a is not defined ]

 >>> a = a+5 [name a is not defined ]

 >>> a = 5 [automatically declared when you


assign value]
Variables:
 Variables are used to hold data during execution of the
program .

 In C , C++ , You need to declare variables . Only after


declaration you can use them.

int a ;

float b ;

 In Python you don't declare variables . If there is a need


of a variable you think of a name and start using it as a
variable
Variable Name:
 Variable name is any combination of alphabet , digit and
underscore .

 Variable name cannot start with digit.

 Variable names are case sensitive.

 Keywords cannot be used as variable names.

 x = 10

del x

 In C/ C++/Java statement ; ← semicolon


Dynamic Type:
 Not only the value of a variable may change during
program execution but the type as well.

 x=5 # type of x is int

 x = 5.7 # type of x is float

 x = True # type of x is bool

 x = “BITR" # type of x is str


Dynamic Type:
 Statically type-> everything is fined before runtime [at
compile time)

 train reservation example.

 Data Categories Data type: int, float, str

 Type of human: ईसान, शैतान, भगवान type

 a=5 a baggage Counter example{token /bag)

 object [techincally-> id (address [reference) ]

 For 5 to 10 years PM -> Narendra Modi

 print (a, b, c, sep="_")


 print (a,b,c, end = “?“)
Dynamic Type:
type():
 type () is a predefined function which returns the data
type of a specified variable.

x=5

type (x)

x = 5.7

type (x)

data type is always a class in Python


Data Types:
 Numbers

int 5

float 3. 7

complex 3+4j

 Boolean

bool True / false

 String

str ‘Ajay’ or “Ajay” or """Ajay """ or ’’' Ajay’’'

 double is not there in Python

 Char is not there in Python


Memory Management:
Garbage Collection:
 It is a program , invoked by Python itself , whenever
required , whose job is to release memory of Garbage
blocks ( object which is not referenced by any name).

What is an Object?

 Object is read world entity Or Object is an instance of a


class.

 Object is a proper noun and Class is a common noun.

Doctor → common noun class

Dr. dixit → Proper noun object

Dr. Sharma → Proper noun object


Name belongs to whom?:
 Name in namespace is a variable which is used to contain
id(reference) of

① Instance object

② Function object

③ class object

 In Python everything is an object.


Print():
 print simple text print ( " welcome" )

 print variable value print ( x)

 print expression print ( x+5*3)

 print multiple value print ( X , Y)

 Sep

 end
Keywords and import:
 ① what is module in Python?

 ② Keywords

 ③ help () on Python shell


Module, Package & Library:
Module:

It is a Python file .

It can contain instance objects, function objects and class


objects.

In simple words , it contains variables, functions and


classes.

Package:

 package is a collection of modules and sub – packages.

Library:

Library is a collection of packages.


import:
 import A2

 Module_Name.module_Element

 Module_Element can be

→ variable (Instance object) module


→ function
→ class

 To import a particular

element only:

From A2 import x

print(x)
import:
Keywords:
help():

 >>> help()

 >>> (String prompt)


Type conversion and number system:
 Type conversion

 Number System

 Conversion of number system

 Unicode

 Taking input from user.


Type conversion:
 a=5 → int

 b= "5” → Str

 a+b int + Str Error

 a+ int( b) int + int No error

10 → int

 str(a) + b Str + str No error

"55“ → Str
Type conversion functions:
 int()

 float ()

 complex ()

 bool ()

 str ()
Number System:
Number System:
Conversion of Number System:
 x= 25

 bin(x) → ‘0b 11001’

 Oct(x) → ‘0o31’

 hex(x) → ‘0x19’

 x = 0b 11001

 x = 0o31

 x = 0x19
Unicode:
 The Unicode is character encoding , and its goal is to
replace the existing character sets with its standard UTF.

 UTF - Unicode Transformation Format

 UTF -8 is the most commonly used character encoding.

 It is also backward compatible with ASCII.

character to Unicode

 x=‘A’ ord(x) → 65

Unicode to character

 x=65 chr(x) → ‘A’


Taking Input From User:
 input ()

 input () can take at most one argument of Str type.

 input () always return Str type value

You might also like