SlideShare a Scribd company logo
1 of 49
UNIT I – Part 1
3/7/2023 1
UNIT 1
Python - Introduction
- widely used general-purpose, high level
programming language
- Python Programming was created by Dutch
Programmer, and released in
1991.
- Further developed by the Python Software
Foundation
- emphasises on code readability, and syntax
- allows programmers to express their concepts in
fewer lines of code.
3/7/2023 2
UNIT 1
Guido van Rossum,
Why is Python called Python?
- Guido van Rossum named it after the television
comedy show Monty Python's Flying Circus
- between 1969 and 1974, which is still well-known
and watched around the world.
- Many Python examples and tutorials include jokes
from the show.
3/7/2023 3
UNIT 1
History of Python
- Python laid its foundation in the late 1980s.
- The implementation of Python was started in
December 1989 by Guido Van Rossum at CWI
(Centrum Wiskunde & Informatica )in Netherland.
- In February 1991, Guido Van Rossum published
the code (labeled version 0.9.0)
- In 1994, Python 1.0 was released with new features
like lambda, map, filter, and reduce.
3/7/2023 4
UNIT 1
History of Python (Continued)
- Python 2.0 added new features such as list
comprehensions, garbage collection systems.
- On December 3, 2008, Python 3.0 (also called
"Py3K") was released. It was designed to rectify the
fundamental flaw of the language.
- ABC programming language is said to be the
predecessor of Python language, which was capable
of Exception Handling and interfacing with the
Amoeba Operating System.
- The following programming languages influence
Python:
– ABC language.
– Modula-3
3/7/2023 5
UNIT 1
Python – Version List
Version Released Date
Python 1.0 January 1994
Python 1.5 December 31, 1997
Python 1.6 September 5, 2000
Python 2.0 October 16, 2000
Python 2.1 April 17, 2001
Python 2.2 December 21, 2001
Python 2.3 July 29, 2003
Python 2.4 November 30, 2004
Python 2.5 September 19, 2006
Python 2.6 October 1, 2008
Python 2.7 July 3, 2010
Version Released Date
Python 3.0 December 3, 2008
Python 3.1 June 27, 2009
Python 3.2 February 20, 2011
Python 3.3 September 29, 2012
Python 3.4 March 16, 2014
Python 3.5 September 13, 2015
Python 3.6 December 23, 2016
Python 3.7 June 27, 2018
Python 3.8 October 14, 2019
Python 3.9.6 June 28, 2021
Python 3.10.2 January 10,2022
3/7/2023 6
UNIT 1
Features of Python
1) Easy to Learn and Use
- Its syntax is straightforward and same as the
English language.
- There is no use of the semicolon or curly-bracket,
the indentation defines the code block.
2) Expressive Language
- can perform complex tasks using a few lines of
code.
3/7/2023 7
UNIT 1
Features of Python (Continued)
3) Interpreted Language
- is an interpreted language;(i.e) the Python program
is executed one line at a time which makes
debugging easy
4) Cross-platform Language
- can run equally on different platforms such as
Windows, Linux, UNIX, and Macintosh, etc by
writing a program only once.
3/7/2023 8
UNIT 1
Features of Python (Continued)
5) Free and Open Source
- It is freely available on its official
website www.python.org.
- "Anyone can download its source code without
paying any penny."
6) Object-Oriented Language
- Python supports object-oriented language and
concepts of classes and objects come into existence.
- supports inheritance, polymorphism, and
encapsulation, etc.
- helps to write reusable code and develop applications
in less code.
3/7/2023 9
UNIT 1
Features of Python (Continued)
7) Extensible
- implies that other languages such as C/C++ can be
used to compile the code and thus it can be used
further in our Python code.
- converts the program into byte code, and any
platform can use that byte code.
8) Large Standard Library
- provides a vast range of libraries for the various
fields such as machine learning, web developer, and
also for the scripting.
3/7/2023 10
UNIT 1
Features of Python (Continued)
9) GUI Programming Support
- Graphical User Interface is used for the developing
Desktop application.
10. Dynamic Memory Allocation
- need not specify the data-type of the variable.
- When value is assigned to a variable, it automatically
allocates the memory to the variable at run time. Suppose
integer value 15 is assigned to x , no need to write int x =
15. Just write x = 15.
3/7/2023 11
UNIT 1
Writing and Executing First Python
Python can be installed using Python Console.
www.python.org.
Python console can be used in several ways:
Two ways mentioned:
1. Using Command line and running interpreter directly
2. GUI software comes with installed python called as
Python’s Integrated Development and Learning
Environment (IDLE)
- Running the IDLE gives a prompt window of three
right rows
- Instructions are typed at the prompt and press ENTER
3/7/2023 12
UNIT 1
Writing and Executing First Python
The >>> symbol denotes the Python Prompt
- Python IDLE works on different platforms (windows,
Unix , MacOS)
- IDLE contains:
• Shell window,
• interactive interpreter,
• debugger,
• multi-window text editor (features like colorizing,
smart indent, call tips and auto completion)
- REPL editors can also be used.
3/7/2023 13
UNIT 1
(Read,Evaluate, Print, Loop)
Writing and Executing First Python
Standard way to save & run a python program:
Step 1: Open an Editor.
Step 2: Write the instructions
Step 3: Save it as a file with the filename having the
extension .py
Step 4: Run the interpreter using python
program_name.py or using IDLE can run
Execute the program in python shell , press F5 (click
RUN menu & select RUN Module)
Exit from IDLE: File-> Exit or ctrl+Q or type quit() at
command prompt
3/7/2023 14
UNIT 1
First Python Program
To print a message:
print (“Hello”)
To add two integers:
print (2 + 3)
3/7/2023 15
UNIT 1
Literal Constants - NUMBERS
Literal Constants:
Literal – means literally .
- Value of literal constant can be used in programs
directly Eg: 7, 3.9,’A’,”Hello” - value cannot be
changed.
Numbers:
Refers to numeric value.
3/7/2023 16
UNIT 1
COMPLEX NUMBERS
-3+7i
INTEGER eg: 5,7
LONG INTEGERS eg:
53546788999L
FLOATING POINT
3.23, 91.5E-2
NUMBER
- Commas are not used in numeric literals or
numeric values
- Floating point range 16 to 17 digits
Literal Constants - NUMBERS
Issues in dealing with floating point numbers:
3/7/2023 UNIT 1 17
Arithmetic
overflow problem
Loss of Precision
Arithmetic
underflow
problem
- Multiply two very
large floating point
numbers is called as
arithmetic overflow.
- It is called as infinity.
- Division of two
floating numbers
resulting in small
magnitiude is called as
arithmetic underflow.
- Loss of precision
repeated infinitely
- Eg:1/3 = .333333
Literal Constants - NUMBERS
Built-in format()
- Any floating-point value may contain an arbitrary
number of decimal places hence should use built-
in format().
- float(16/float(3))) 5.3333333333333
- float(16/float(3))), ‘.2f’) 5.3
- format(3**50,’.5e’) 7.17898e+23
- format(123456, ‘,’) 123,456
3/7/2023 UNIT 1 18
Literal Constants - NUMBERS
Simple Operations on Numbers
- Python carry out simple operations on numbers and type the operations
to be performed on to python console.
Eg: 50 + 40 – 35 55
- Division by Zero
Generates an error & no output is produced.
Eg:
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 15/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
3/7/2023 UNIT 1 19
Literal Constants - NUMBERS
- Dividing two integers:
if any two integer values are divided it produce a
floating point number.
- Python automatically converts integer to float called
as implicit conversion (type coercion).
Example:
>>> 5*3.0
15.0
>>> 19+3.5
22.5
3/7/2023 UNIT 1 20
Literal Constants - NUMBERS
- Quotient and Remainder:
To find the quotient of two numbers floor division(//) is used.
To find the remainder of two numbers division modulo operator(%)
is used.
Exponentiation:
Python also supports ** operator.
Eg:
22.5
>>> 5**3
125
>>> 121**0.5
11.0
3/7/2023 UNIT 1 21
Literal Constants - STRINGS
A STRING is a group of characters.
- Using Single Quotes(‘)
- Using Double Quotes(“)
- Using Triple Quotes(‘’ ‘ ‘’ ‘) – multi-line strings
Eg;
''' Good Morning everyone
... "welcome to CSDA'python'."happy reading'''
' Good Morning everyonen"welcome to
CSDA'python'."happy reading'
3/7/2023 UNIT 1 22
Literal Constants - STRINGS
Escape Sequences:
Eg:>>> print('what's your name?')
File "<stdin>", line 1
print('what's your name?')
^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a
comma?
>>> print('What's your name?')
What's your name?
>>>
3/7/2023 UNIT 1 23
Literal Constants - STRINGS
Escape
Sequences
Purpose Example Output
 Print Backslash Print(“”) 
’ Print single-quote Print(“’”) ‘
” Print double-quote Print(“” ”) “
a Ring bell Print(“a”) Bell rings
f Print form feed
character
Print(“Hellof
World”)
Hello World
n Prints newline
character
Print(“Hellon
world”)
Hello World
t Prints a tab Print(“Hellot
World”)
Hello World
o Print octal values Print(“o56”) .
x Print hex values Print(“x87”) +
3/7/2023 UNIT 1 24
Literal Constants - STRINGS
Raw Strings:
A string that should display exactly as specified is
called as raw string.
It is specified by prefixing r or R to the string.
Example:
>>> print(R"what 's ur name")
what 's ur name
3/7/2023 UNIT 1 25
Literal Constants - STRINGS
String Formatting:
To format the floating point number built-in format
function is used.
Syntax:
Format(value, format_specifier)
3/7/2023 UNIT 1 26
Value or the string Combination of
formatting options
Literal Constants - STRINGS
Example
>>> format ('hello', '<30')
'hello '
>>> format ('hello','>30')
' hello'
>>> format("hello", "^30")
' hello '
>>>print("hello",format('-','-<10'),"world")
hello ---------- world
3/7/2023 UNIT 1 27
Variables
- A Python variable is a reserved memory location to
store values.
- In other words, a variable in python program gives
data to the computer for processing.
- Its value can be varied.
- A Python identifier is a name used to identify a
variable, function, class, module or other object.
3/7/2023 28
UNIT 1
Identifiers
-
Rules for Python identifiers:
- An identifier starts with a letter A to Z or a to z or an
underscore ( _ ) followed by zero or more letters,
underscores and digits (0 to 9).
- Python does not allow punctuation characters such as @,
$, and % within identifiers.
- Python is a case sensitive programming language.
Thus, Manpower and manpower are two different
identifiers in Python.
- Eg: valid identifier:sum, _my_var, num1, r , var_20, First
- Invalid indentifier: 1num, my-var, %check, Basic Sal 29
3/7/2023 UNIT 1
Identifiers (Continued)
Here are naming conventions for Python identifiers :
- Class names start with an uppercase letter. All other
identifiers start with a lowercase letter.
Srcas is Valid and SRCAS is not valid
- Starting an identifier with a single leading underscore
indicates that the identifier is private.
- Starting an identifier with two leading underscores
indicates a strongly private identifier.
- If the identifier also ends with two trailing underscores,
the identifier is a language-defined special name.
- Reserved key words cannot be an identifier
3/7/2023 30
UNIT 1
Data Types
- Variables can hold values of different types called as
datatypes.
- Different datatypes is required to store different types
of values in the variables.
- Divided into two categories
Immutable Data Types:
(i) Numeric, (ii) String (iii) Tuple
Mutable Data Types:
(i) List, (ii) Dictionary (iii) Set
3/7/2023 31
UNIT 1
Data Types (Continued)
1) Numeric
A numeric value is any representation of data
which has a numeric value. Python identifies three
types of numbers:
(a) Integer: Positive or negative whole numbers
(without a fractional part)
(b) Float: Any real number with a floating point
representation in which a fractional component is
denoted by a decimal symbol or scientific notation
(c) Complex number: A number with a real and
imaginary component represented as x+yj.
3/7/2023 32
UNIT 1
Data Types (Continued)
2) String
- String literals in python are surrounded by either
single quotation marks, or double quotation marks.
'hello' is the same as "hello".
3) List
- collection which is ordered and changeable.
Allows duplicate members.
Example:
fruit = [“apple”, “Banana”, “Orange”]
3/7/2023 33
UNIT 1
Data Types (Continued)
4) Tuple:
- collection which is ordered and unchangeable.
Allows duplicate members.
Example:
fruit = (“apple”, “Banana”, “Orange”)
5) Dictionary:
- collection which is unordered, changeable and
indexed, and they have keys and values.
Example:
Student = {“name”: “Raju”, “Age”:18,
“city”:”Kovai”}
3/7/2023 34
UNIT 1
Data Types (Continued)
6) Set
- collection which is unordered and unindexed.
Example:
fruit = {“apple”, “Banana”, “Orange”}
3/7/2023 35
UNIT 1
Data Types –Assigning or
initializing values to variable
- Python need not require explicitly to declare variables
to reserve memory space.
- Declaration done automatically when a value is
assigned with =.
- LHS of operand is the name of the variable;
- RHS of operand is the value stored in that variable.
3/7/2023 36
UNIT 1
Data Types –Assigning or
initializing values to variable
In python reassigning variables can be done as many times.
• Output:
3/7/2023 37
UNIT 1
Data Types –Assigning or
initializing values to variable
Python IDLE remembers variable names and values.
3/7/2023 38
UNIT 1
MULTIPLE ASSIGNMENT
- Python allows programmers to assign a single value
to more than one variables simultaneously
Eg; sum=flag=b=a=0
- Different values to multiple variables simultaneously
Eg; sum, a, b, mesg=0,3,5, “result”
Note: Referencing a variable that has not assigned any
value result to error.
3/7/2023 39
UNIT 1
MULTIPLE ASSIGNMENT
str="hello"
num=10
print(str)
hello
print(age)
Traceback (most recent call
last):
File "<pyshell#3>", line 1, in
<module>
print(age)
NameError: name 'age' is not
defined
3/7/2023 40
str="hello"
num=10
age=10
print(str)
hello
print(num)
10
print(age)
10
del num
print(num)
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
print(num)
NameError: name 'num' is not defined.
Did you mean: 'sum'?
UNIT 1
MULTIPLE ASSIGNMENT
Program code two types:
Physical line –
what we see while writing the program
Logical line –
what python sees as a single statement
- More than one statement in a single line
semicolon should be used ;
Eg: all the below syntax are same
med="hello"; med="hello" med="hello“;
print(med); print(med) print(med)
3/7/2023 41
UNIT 1
Boolean
- Another datatype in python
- It can contain two values TRUE or FALSE.
- It is created while assigning a value or with
relational operator.
- It is also created by comparing values using the
== operator.
3/7/2023 42
UNIT 1
Boolean - Examples
boolean_var= True
print(boolean_var)
True
20!= 20
False
90<=90
True
87<87.0
False
20==30
False
3/7/2023 43
"python"!="python3.4"
True
87==87.0
True
87>=87.0
True
"PYTHON"=="PYTHON"
True
30> 50
False
UNIT 1
Input Operation
Python is interactive: To get input or information
from the user.
input() function is used.
- Prompts the user to provide some information,
process and the provide the result.
- This function takes user’s input as a string
Hence a number is taken as input it treats as
string only
3/7/2023 44
UNIT 1
Input Operation
Program:
name=input("What's your name?")
age=input("Enter your age")
print(name +",you are" + age + years old")
Output:
What's your
name?vidhya
Enter your
age39
vidhya,you
are39years
old
3/7/2023 45
Older versions used raw_input() as input function
UNIT 1
Comments
- Comments are non-executable statements in a program.
- They are added to describe the statements in the
program code.
- Comments make the program easily readable &
understandable .
- Interpreter simply ignore the comments.
- # indicate the comment line.
Example:
# this is a comment
Print(“hello”) # to display
# program ends here
3/7/2023 46
UNIT 1
Reserved Keywords
- Reserved words (also called keywords) are
defined with predefined meaning and syntax in
the language.
- Reserved words can’t be used as
identifiers like
name of variable,
function etc.
3/7/2023 47
UNIT 1
and except lambda with
as finally nonlocal while
assert false none yield
break for not
class from or
continue global pass
def if raise
del import return
elif in true
else is TRY
Indentation
- White space at the beginning of the line is called
as Indentation.
- White space or the indentation is important.
- In python indentation is used to associate and
group statements.
- EXAMPLE
3/7/2023 48
UNIT 1
Indentation
- The level of indentation groups
statements to form a block of
statements
- In a block same indentation level to be
maintained for that group of
statements.
- Indent not correct is denoted by ^.
- Indent in python does not use {….}
3/7/2023 49
UNIT 1

More Related Content

Similar to Python_Unit1_Introduction.pptx

PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
manikamr074
 
Python_Session
Python_SessionPython_Session
Python_Session
siva ram
 

Similar to Python_Unit1_Introduction.pptx (20)

Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
An Introduction to OMNeT++ 5.4
An Introduction to OMNeT++ 5.4An Introduction to OMNeT++ 5.4
An Introduction to OMNeT++ 5.4
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-python
 
Python programming lanuguage
Python programming lanuguagePython programming lanuguage
Python programming lanuguage
 
Report om 3
Report om 3Report om 3
Report om 3
 
python PPT Session 1.pptx
python PPT Session 1.pptxpython PPT Session 1.pptx
python PPT Session 1.pptx
 
Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++
 
kecs105.pdf
kecs105.pdfkecs105.pdf
kecs105.pdf
 
علم البيانات - Data Sience
علم البيانات - Data Sience علم البيانات - Data Sience
علم البيانات - Data Sience
 
Savitch ch 01
Savitch ch 01Savitch ch 01
Savitch ch 01
 
Savitch ch 01
Savitch ch 01Savitch ch 01
Savitch ch 01
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
 
Python_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdfPython_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdf
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
 
Python_vision_academy notes
Python_vision_academy notes Python_vision_academy notes
Python_vision_academy notes
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
 
Python basics
Python basicsPython basics
Python basics
 
Python_Session
Python_SessionPython_Session
Python_Session
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Ernest Hemingway's For Whom the Bell Tolls
Ernest Hemingway's For Whom the Bell TollsErnest Hemingway's For Whom the Bell Tolls
Ernest Hemingway's For Whom the Bell Tolls
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Pharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdfPharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdf
 
PUBLIC FINANCE AND TAXATION COURSE-1-4.pdf
PUBLIC FINANCE AND TAXATION COURSE-1-4.pdfPUBLIC FINANCE AND TAXATION COURSE-1-4.pdf
PUBLIC FINANCE AND TAXATION COURSE-1-4.pdf
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 

Python_Unit1_Introduction.pptx

  • 1. UNIT I – Part 1 3/7/2023 1 UNIT 1
  • 2. Python - Introduction - widely used general-purpose, high level programming language - Python Programming was created by Dutch Programmer, and released in 1991. - Further developed by the Python Software Foundation - emphasises on code readability, and syntax - allows programmers to express their concepts in fewer lines of code. 3/7/2023 2 UNIT 1 Guido van Rossum,
  • 3. Why is Python called Python? - Guido van Rossum named it after the television comedy show Monty Python's Flying Circus - between 1969 and 1974, which is still well-known and watched around the world. - Many Python examples and tutorials include jokes from the show. 3/7/2023 3 UNIT 1
  • 4. History of Python - Python laid its foundation in the late 1980s. - The implementation of Python was started in December 1989 by Guido Van Rossum at CWI (Centrum Wiskunde & Informatica )in Netherland. - In February 1991, Guido Van Rossum published the code (labeled version 0.9.0) - In 1994, Python 1.0 was released with new features like lambda, map, filter, and reduce. 3/7/2023 4 UNIT 1
  • 5. History of Python (Continued) - Python 2.0 added new features such as list comprehensions, garbage collection systems. - On December 3, 2008, Python 3.0 (also called "Py3K") was released. It was designed to rectify the fundamental flaw of the language. - ABC programming language is said to be the predecessor of Python language, which was capable of Exception Handling and interfacing with the Amoeba Operating System. - The following programming languages influence Python: – ABC language. – Modula-3 3/7/2023 5 UNIT 1
  • 6. Python – Version List Version Released Date Python 1.0 January 1994 Python 1.5 December 31, 1997 Python 1.6 September 5, 2000 Python 2.0 October 16, 2000 Python 2.1 April 17, 2001 Python 2.2 December 21, 2001 Python 2.3 July 29, 2003 Python 2.4 November 30, 2004 Python 2.5 September 19, 2006 Python 2.6 October 1, 2008 Python 2.7 July 3, 2010 Version Released Date Python 3.0 December 3, 2008 Python 3.1 June 27, 2009 Python 3.2 February 20, 2011 Python 3.3 September 29, 2012 Python 3.4 March 16, 2014 Python 3.5 September 13, 2015 Python 3.6 December 23, 2016 Python 3.7 June 27, 2018 Python 3.8 October 14, 2019 Python 3.9.6 June 28, 2021 Python 3.10.2 January 10,2022 3/7/2023 6 UNIT 1
  • 7. Features of Python 1) Easy to Learn and Use - Its syntax is straightforward and same as the English language. - There is no use of the semicolon or curly-bracket, the indentation defines the code block. 2) Expressive Language - can perform complex tasks using a few lines of code. 3/7/2023 7 UNIT 1
  • 8. Features of Python (Continued) 3) Interpreted Language - is an interpreted language;(i.e) the Python program is executed one line at a time which makes debugging easy 4) Cross-platform Language - can run equally on different platforms such as Windows, Linux, UNIX, and Macintosh, etc by writing a program only once. 3/7/2023 8 UNIT 1
  • 9. Features of Python (Continued) 5) Free and Open Source - It is freely available on its official website www.python.org. - "Anyone can download its source code without paying any penny." 6) Object-Oriented Language - Python supports object-oriented language and concepts of classes and objects come into existence. - supports inheritance, polymorphism, and encapsulation, etc. - helps to write reusable code and develop applications in less code. 3/7/2023 9 UNIT 1
  • 10. Features of Python (Continued) 7) Extensible - implies that other languages such as C/C++ can be used to compile the code and thus it can be used further in our Python code. - converts the program into byte code, and any platform can use that byte code. 8) Large Standard Library - provides a vast range of libraries for the various fields such as machine learning, web developer, and also for the scripting. 3/7/2023 10 UNIT 1
  • 11. Features of Python (Continued) 9) GUI Programming Support - Graphical User Interface is used for the developing Desktop application. 10. Dynamic Memory Allocation - need not specify the data-type of the variable. - When value is assigned to a variable, it automatically allocates the memory to the variable at run time. Suppose integer value 15 is assigned to x , no need to write int x = 15. Just write x = 15. 3/7/2023 11 UNIT 1
  • 12. Writing and Executing First Python Python can be installed using Python Console. www.python.org. Python console can be used in several ways: Two ways mentioned: 1. Using Command line and running interpreter directly 2. GUI software comes with installed python called as Python’s Integrated Development and Learning Environment (IDLE) - Running the IDLE gives a prompt window of three right rows - Instructions are typed at the prompt and press ENTER 3/7/2023 12 UNIT 1
  • 13. Writing and Executing First Python The >>> symbol denotes the Python Prompt - Python IDLE works on different platforms (windows, Unix , MacOS) - IDLE contains: • Shell window, • interactive interpreter, • debugger, • multi-window text editor (features like colorizing, smart indent, call tips and auto completion) - REPL editors can also be used. 3/7/2023 13 UNIT 1 (Read,Evaluate, Print, Loop)
  • 14. Writing and Executing First Python Standard way to save & run a python program: Step 1: Open an Editor. Step 2: Write the instructions Step 3: Save it as a file with the filename having the extension .py Step 4: Run the interpreter using python program_name.py or using IDLE can run Execute the program in python shell , press F5 (click RUN menu & select RUN Module) Exit from IDLE: File-> Exit or ctrl+Q or type quit() at command prompt 3/7/2023 14 UNIT 1
  • 15. First Python Program To print a message: print (“Hello”) To add two integers: print (2 + 3) 3/7/2023 15 UNIT 1
  • 16. Literal Constants - NUMBERS Literal Constants: Literal – means literally . - Value of literal constant can be used in programs directly Eg: 7, 3.9,’A’,”Hello” - value cannot be changed. Numbers: Refers to numeric value. 3/7/2023 16 UNIT 1 COMPLEX NUMBERS -3+7i INTEGER eg: 5,7 LONG INTEGERS eg: 53546788999L FLOATING POINT 3.23, 91.5E-2 NUMBER - Commas are not used in numeric literals or numeric values - Floating point range 16 to 17 digits
  • 17. Literal Constants - NUMBERS Issues in dealing with floating point numbers: 3/7/2023 UNIT 1 17 Arithmetic overflow problem Loss of Precision Arithmetic underflow problem - Multiply two very large floating point numbers is called as arithmetic overflow. - It is called as infinity. - Division of two floating numbers resulting in small magnitiude is called as arithmetic underflow. - Loss of precision repeated infinitely - Eg:1/3 = .333333
  • 18. Literal Constants - NUMBERS Built-in format() - Any floating-point value may contain an arbitrary number of decimal places hence should use built- in format(). - float(16/float(3))) 5.3333333333333 - float(16/float(3))), ‘.2f’) 5.3 - format(3**50,’.5e’) 7.17898e+23 - format(123456, ‘,’) 123,456 3/7/2023 UNIT 1 18
  • 19. Literal Constants - NUMBERS Simple Operations on Numbers - Python carry out simple operations on numbers and type the operations to be performed on to python console. Eg: 50 + 40 – 35 55 - Division by Zero Generates an error & no output is produced. Eg: Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 15/0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero 3/7/2023 UNIT 1 19
  • 20. Literal Constants - NUMBERS - Dividing two integers: if any two integer values are divided it produce a floating point number. - Python automatically converts integer to float called as implicit conversion (type coercion). Example: >>> 5*3.0 15.0 >>> 19+3.5 22.5 3/7/2023 UNIT 1 20
  • 21. Literal Constants - NUMBERS - Quotient and Remainder: To find the quotient of two numbers floor division(//) is used. To find the remainder of two numbers division modulo operator(%) is used. Exponentiation: Python also supports ** operator. Eg: 22.5 >>> 5**3 125 >>> 121**0.5 11.0 3/7/2023 UNIT 1 21
  • 22. Literal Constants - STRINGS A STRING is a group of characters. - Using Single Quotes(‘) - Using Double Quotes(“) - Using Triple Quotes(‘’ ‘ ‘’ ‘) – multi-line strings Eg; ''' Good Morning everyone ... "welcome to CSDA'python'."happy reading''' ' Good Morning everyonen"welcome to CSDA'python'."happy reading' 3/7/2023 UNIT 1 22
  • 23. Literal Constants - STRINGS Escape Sequences: Eg:>>> print('what's your name?') File "<stdin>", line 1 print('what's your name?') ^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma? >>> print('What's your name?') What's your name? >>> 3/7/2023 UNIT 1 23
  • 24. Literal Constants - STRINGS Escape Sequences Purpose Example Output Print Backslash Print(“”) ’ Print single-quote Print(“’”) ‘ ” Print double-quote Print(“” ”) “ a Ring bell Print(“a”) Bell rings f Print form feed character Print(“Hellof World”) Hello World n Prints newline character Print(“Hellon world”) Hello World t Prints a tab Print(“Hellot World”) Hello World o Print octal values Print(“o56”) . x Print hex values Print(“x87”) + 3/7/2023 UNIT 1 24
  • 25. Literal Constants - STRINGS Raw Strings: A string that should display exactly as specified is called as raw string. It is specified by prefixing r or R to the string. Example: >>> print(R"what 's ur name") what 's ur name 3/7/2023 UNIT 1 25
  • 26. Literal Constants - STRINGS String Formatting: To format the floating point number built-in format function is used. Syntax: Format(value, format_specifier) 3/7/2023 UNIT 1 26 Value or the string Combination of formatting options
  • 27. Literal Constants - STRINGS Example >>> format ('hello', '<30') 'hello ' >>> format ('hello','>30') ' hello' >>> format("hello", "^30") ' hello ' >>>print("hello",format('-','-<10'),"world") hello ---------- world 3/7/2023 UNIT 1 27
  • 28. Variables - A Python variable is a reserved memory location to store values. - In other words, a variable in python program gives data to the computer for processing. - Its value can be varied. - A Python identifier is a name used to identify a variable, function, class, module or other object. 3/7/2023 28 UNIT 1
  • 29. Identifiers - Rules for Python identifiers: - An identifier starts with a letter A to Z or a to z or an underscore ( _ ) followed by zero or more letters, underscores and digits (0 to 9). - Python does not allow punctuation characters such as @, $, and % within identifiers. - Python is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in Python. - Eg: valid identifier:sum, _my_var, num1, r , var_20, First - Invalid indentifier: 1num, my-var, %check, Basic Sal 29 3/7/2023 UNIT 1
  • 30. Identifiers (Continued) Here are naming conventions for Python identifiers : - Class names start with an uppercase letter. All other identifiers start with a lowercase letter. Srcas is Valid and SRCAS is not valid - Starting an identifier with a single leading underscore indicates that the identifier is private. - Starting an identifier with two leading underscores indicates a strongly private identifier. - If the identifier also ends with two trailing underscores, the identifier is a language-defined special name. - Reserved key words cannot be an identifier 3/7/2023 30 UNIT 1
  • 31. Data Types - Variables can hold values of different types called as datatypes. - Different datatypes is required to store different types of values in the variables. - Divided into two categories Immutable Data Types: (i) Numeric, (ii) String (iii) Tuple Mutable Data Types: (i) List, (ii) Dictionary (iii) Set 3/7/2023 31 UNIT 1
  • 32. Data Types (Continued) 1) Numeric A numeric value is any representation of data which has a numeric value. Python identifies three types of numbers: (a) Integer: Positive or negative whole numbers (without a fractional part) (b) Float: Any real number with a floating point representation in which a fractional component is denoted by a decimal symbol or scientific notation (c) Complex number: A number with a real and imaginary component represented as x+yj. 3/7/2023 32 UNIT 1
  • 33. Data Types (Continued) 2) String - String literals in python are surrounded by either single quotation marks, or double quotation marks. 'hello' is the same as "hello". 3) List - collection which is ordered and changeable. Allows duplicate members. Example: fruit = [“apple”, “Banana”, “Orange”] 3/7/2023 33 UNIT 1
  • 34. Data Types (Continued) 4) Tuple: - collection which is ordered and unchangeable. Allows duplicate members. Example: fruit = (“apple”, “Banana”, “Orange”) 5) Dictionary: - collection which is unordered, changeable and indexed, and they have keys and values. Example: Student = {“name”: “Raju”, “Age”:18, “city”:”Kovai”} 3/7/2023 34 UNIT 1
  • 35. Data Types (Continued) 6) Set - collection which is unordered and unindexed. Example: fruit = {“apple”, “Banana”, “Orange”} 3/7/2023 35 UNIT 1
  • 36. Data Types –Assigning or initializing values to variable - Python need not require explicitly to declare variables to reserve memory space. - Declaration done automatically when a value is assigned with =. - LHS of operand is the name of the variable; - RHS of operand is the value stored in that variable. 3/7/2023 36 UNIT 1
  • 37. Data Types –Assigning or initializing values to variable In python reassigning variables can be done as many times. • Output: 3/7/2023 37 UNIT 1
  • 38. Data Types –Assigning or initializing values to variable Python IDLE remembers variable names and values. 3/7/2023 38 UNIT 1
  • 39. MULTIPLE ASSIGNMENT - Python allows programmers to assign a single value to more than one variables simultaneously Eg; sum=flag=b=a=0 - Different values to multiple variables simultaneously Eg; sum, a, b, mesg=0,3,5, “result” Note: Referencing a variable that has not assigned any value result to error. 3/7/2023 39 UNIT 1
  • 40. MULTIPLE ASSIGNMENT str="hello" num=10 print(str) hello print(age) Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> print(age) NameError: name 'age' is not defined 3/7/2023 40 str="hello" num=10 age=10 print(str) hello print(num) 10 print(age) 10 del num print(num) Traceback (most recent call last): File "<pyshell#12>", line 1, in <module> print(num) NameError: name 'num' is not defined. Did you mean: 'sum'? UNIT 1
  • 41. MULTIPLE ASSIGNMENT Program code two types: Physical line – what we see while writing the program Logical line – what python sees as a single statement - More than one statement in a single line semicolon should be used ; Eg: all the below syntax are same med="hello"; med="hello" med="hello“; print(med); print(med) print(med) 3/7/2023 41 UNIT 1
  • 42. Boolean - Another datatype in python - It can contain two values TRUE or FALSE. - It is created while assigning a value or with relational operator. - It is also created by comparing values using the == operator. 3/7/2023 42 UNIT 1
  • 43. Boolean - Examples boolean_var= True print(boolean_var) True 20!= 20 False 90<=90 True 87<87.0 False 20==30 False 3/7/2023 43 "python"!="python3.4" True 87==87.0 True 87>=87.0 True "PYTHON"=="PYTHON" True 30> 50 False UNIT 1
  • 44. Input Operation Python is interactive: To get input or information from the user. input() function is used. - Prompts the user to provide some information, process and the provide the result. - This function takes user’s input as a string Hence a number is taken as input it treats as string only 3/7/2023 44 UNIT 1
  • 45. Input Operation Program: name=input("What's your name?") age=input("Enter your age") print(name +",you are" + age + years old") Output: What's your name?vidhya Enter your age39 vidhya,you are39years old 3/7/2023 45 Older versions used raw_input() as input function UNIT 1
  • 46. Comments - Comments are non-executable statements in a program. - They are added to describe the statements in the program code. - Comments make the program easily readable & understandable . - Interpreter simply ignore the comments. - # indicate the comment line. Example: # this is a comment Print(“hello”) # to display # program ends here 3/7/2023 46 UNIT 1
  • 47. Reserved Keywords - Reserved words (also called keywords) are defined with predefined meaning and syntax in the language. - Reserved words can’t be used as identifiers like name of variable, function etc. 3/7/2023 47 UNIT 1 and except lambda with as finally nonlocal while assert false none yield break for not class from or continue global pass def if raise del import return elif in true else is TRY
  • 48. Indentation - White space at the beginning of the line is called as Indentation. - White space or the indentation is important. - In python indentation is used to associate and group statements. - EXAMPLE 3/7/2023 48 UNIT 1
  • 49. Indentation - The level of indentation groups statements to form a block of statements - In a block same indentation level to be maintained for that group of statements. - Indent not correct is denoted by ^. - Indent in python does not use {….} 3/7/2023 49 UNIT 1