0% found this document useful (0 votes)
4 views37 pages

pythonUNIT_1

The document outlines a Python Programming course offered by the School of Computer Science and Applications, detailing course objectives, content, and reading materials. It covers fundamental concepts such as Object-Oriented Programming, control structures, functions, exception handling, and file operations. The syllabus is divided into four units, with a focus on practical applications and programming techniques in Python.

Uploaded by

projectdemo091
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views37 pages

pythonUNIT_1

The document outlines a Python Programming course offered by the School of Computer Science and Applications, detailing course objectives, content, and reading materials. It covers fundamental concepts such as Object-Oriented Programming, control structures, functions, exception handling, and file operations. The syllabus is divided into four units, with a focus on practical applications and programming techniques in Python.

Uploaded by

projectdemo091
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Established as per the Section 2(f) of the UGC Act, 1956

Approved by AICTE, COA and BCI, New Delhi

Python Programming

School of Computer Science and Applications

Prof. Lokesh C K
16/02/2022
AGENDA

• Course Objectives
• Course Content
• Reading Materials
• Course Outcomes
• Overview of the Prerequisite
COURSE OBJECTIVE

1.Introduce the concepts of OOPs in Python programming.


2.Illustrate the usage of control structures with basic and advanced data
types
3.Demonstrate the need of python functions & Exception handling
4.Discuss the file handling mechanism with file I/O operations.
UNIT WISE SYLLABUS
Unit 1
Introduction to Python: Getting started: Introducing python, setting up python on windows and
other operating systems, introducing IDLE Py Ingredients: Numbers, Strings, and Variables:
Variables, Names and Objects, Numbers, Strings.

UNIT II: 13 Hours


Advanced Data Structures & Control structures: Py Filling: Lists, Tuples, Dictionaries, and Sets:
Lists and Tuples, Lists, Tuples , Dictionaries, Sets, Compare Data Structures. Py Crust: Code
Structures: Comment with #, Continue Lines with \ , Compare with if, elif, and else, Repeat
with while, Iterate with for.
UNIT WISE SYLLABUS

UNIT III: 13 Hours


Functions & Exception Handling: Functions: Positional Arguments, Keyword Arguments ,
Specify Default Parameter Values, Gather Positional Arguments with *, Gather Keyword
Arguments with ** , Docstrings , Inner Functions, Anonymous Functions: the lambda()
Function. Generators, Decorators, Namespaces and Scope, Uses of _ and __ in Names ,
Handle Errors with try and except, Make Your Own Exceptions.
UNIT IV: 13 Hours
OOPs concepts & Files: Oh Oh: Objects and Classes: What Are Objects?, Define a Class with
class, Inheritance, Override a Method, Add a Method, Get Help from Your Parent with super,
Get and Set Attribute Values with Properties, Duck typing , Special Methods, Composition.
Data Has to Go Somewhere: File Input/Output, Write a Text File with write(), Read a Text File
with read(), readline(), or readlines(), Write a Binary File with write(), Read a Binary File with
read(), Close Files Automatically by Using with, Change Position with seek().
1. Text Books:
1. Bill Lubanovic , Introducing Python :Modern Computing in Simple Packages , O’reilly Publishers,
2015.
2. Python Programming for absolute beginners by Michael Dawson, Course Technology-A part of
CENGAGE Learning, 3rd Edition

2. References books:
1. Python Programming, Michael Dawson, 3rd Edition, Course technology PTR, 2010.
2. Robert Galanakis, Practical Maya Programming With Python, Shroff Publishers & Distributors,
2014.
3. Mark Lutz , Python Programming, Shroff Publishers & Distributors, 2011
PYTHON

• Python is a general purpose programming language that is often


applied in scripting roles.
• So, Python is programming language as well as scripting
language.
• Python is also called as Interpreted language
DIFFERENCES BETWEEN PROGRAM AND SCRIPTING
LANGUAGE
Program Scripting
• a program is executed (i.e. the • a script is interpreted
source is first compiled, and the • A "script" is code written in a
result of that compilation is
expected) scripting language. A scripting
• A "program" in general, is a language is nothing but a type
sequence of instructions of programming language in
written so that a computer which we can write code to
can perform certain task.
control another software
application.
HISTORY
• Invented in the Netherlands, early 90s by Guido van
Rossum Python was conceived in the late 1980s and
its implementation was started in December 1989
PYTHON INTRODUCTION

• Guido Van Rossum is fan of ‘Monty


Python’s Flying Circus’, this is a famous TV show
in Netherlands
• Named after Monty Python
• Open sourced from the beginning
WHY WAS PYTHON CREATED

1. "My original motivation for creating Python was the perceived need for a
higher level language in the Amoeba [Operating Systems] project.
2. I realized that the development of system. administration utilities in
C was taking too long.
3. Moreover, doing thesethings in the Bourne wouldn't work
for a variety of reasons. ...
4. So, there was a need for a language that would bridge the
gap between C and the shell”
- Guido Van Rossum
WHY PYTHON?
WHAT IS PYTHON?

1. Python is an interpreted, interactive, object-oriented programming


language.
2. It incorporates modules, exceptions, dynamic typing, very high level
dynamic data types, and classes.
3. Python is portable: it runs on many Unix variants including Linux and
macOS, and on Windows.
WHY IS IT CALLED AS PYTHON?

1. When he began implementing Python, Guido van Rossum was also reading
the published scripts from “Monty Python’s Flying Circus”, a BBC comedy
series from the 1970s.
2. Van Rossum thought he needed a name that was short, unique, and
slightly mysterious, so he decided to call the language Python.
HOW DO I OBTAIN A COPY OF THE PYTHON SOURCE?

1. The latest Python source distribution is always available from python.org,


at https://www.python.org/downloads/.
POPULARITY of PYTHON

1. index | TIOBE - The Software Quality Company


PYPL PopularitY of Programming Language index
Why do people use Python…?

1. The following primary factors cited by Python users seem to be


these:

2. Python is object-oriented
3. Structure supports such concepts as polymorphism, operation
overloading, and multiple inheritance.
4. Indentation
5. Indentation is one of the greatest future in Python. It's free (open
source)
6. Downloading and installing Python is free and easy Source code is
easily accessible
FEATURES OF PYTHON PROGRAMMING LANGUAGE

It's powerful
- Dynamic typing
- Built-in types and tools
- Library utilities
- Third party utilities (e.g. Numeric, NumPy, SciPy)
- Automatic memory management
It's portable

- Python runs virtually every major platform used today


-As long as you have a compatible Python interpreter installed, Python
programs will run in exactly the same manner, irrespective of platform.
COMPARISON WITH OTHER
LANGUAGES
FEATURES OF PYTHON PROGRAMMING LANGUAGE

• General Purpose
• High level
• Dynamic
• Scripting
• Object Oriented
• Portable
• Open Source
• Powerful Language
GENERAL PURPOSE
It can be used for building

• System utilities(Disk • Programs on Image


defragmenters, Network Processing
Managers, Application • Programs in the field of
Launchers, Antivirus software, Machine Learning
Backup software, Disk repair, • IoT Devices Programming
Disk Cleaners, Disk Space
analyzer, file manager, File • Building of Games
Compression, Data Security ) • GUIs
• Programs in the field of • Web Applications(gmail,
Artificial Intelligence facebook, Amazon)
• Database Programs
HIGH LEVEL LANGUAGE
What is it??
• English like language which is easily understood by
the user
• Examples-??
DIFFERENCE BETWEEN COMPILER AND
INTERPRETER
DYNAMIC LANGUAGE
What is it??
• static typed languages are those in which type checking is done at
compile-time. Ex: C,C++,Java.

• dynamic typed languages are those in which type checking is done at


run-time. Ex: Python, JavaScript, PHP.
AB- 195, 208, 211,213,219,220, 221,31,37,43,44,47,51,53,55,58
SCRIPTING LANGUAGE
What are the features for it to be called as Scripting Language
• Short Programs are usually called Scripts.
• Dynamic languages are also called as Scripting
Languages
• The language that uses an Interpreter(and that
which doesn’t use Compiler) can be called as
Scripting Language.
OBJECT ORIENTED LANGUAGE
Why is it called as Object Oriented Language??
• OO Language is based on classes
• There exists a collection of interacting objects.
• The four major principles of Object Orientation are
Encapsulation
Data Abstraction
Polymorphism
Inheritance
PORTABLE
What is Portability??
• It runs on many OSs .
• For Ex: Various Unix Variants,
• On Mac,
• Windows 2000 and later
INSTALLING PYTHON

• Python is pre-installed on most Unix systems, including Linux


and MAC OS X
• But for in Windows Operating Systems , user can download
from the https://www.python.org/downloads/
• - from the above link download latest version of python IDE
and install, recent version is 3.9+ but most of them uses
version 3.6.
KEY WORDS
Reserved words
PYTHON DATA TYPES

Python has five standard data types −


1. Numbers
2. String
3. List
4. Tuple
5. Dictionary
6. Python Numbers
7. Number data types store numeric values. Number objects are created
when you assign a value to them.
For example −
var1 = 1
var2 = 10
You can also delete the reference to a number object by using the del
statement. The syntax of the del statement is −
del var1[,var2[,var3[....,varN]]]]
You can delete a single object or multiple objects by using the del statement.
For example −
del var
del var_a, var_b
Python supports four different numerical types −

int (signed integers)


long (long integers, they can also be represented in octal and hexadecimal)
float (floating point real values)
complex (complex numbers)
Number Type Conversion
Python converts numbers internally in an expression containing mixed types
to a common type for evaluation. But sometimes, you need to coerce a
number explicitly from one type to another to satisfy the requirements of an
operator or function parameter.
Type int(x) to convert x to a plain integer.
Type long(x) to convert x to a long integer.
Type float(x) to convert x to a floating-point number.
Type complex(x) to convert x to a complex number with real part x and
imaginary part zero.
Type complex(x, y) to convert x and y to a complex number with real part x
and imaginary part y. x and y are numeric expressions
abs(x)
The absolute value of x: the (positive) distance between x and zero.
ceil(x)
The ceiling of x: the smallest integer not less than x
cmp(x, y)
-1 if x < y, 0 if x == y, or 1 if x > y
exp(x)
The exponential of x: ex
log(x)
The natural logarithm of x, for x> 0
Etc….
Strings are amongst the most popular types in Python. We can create them
simply by enclosing characters in quotes. Python treats single quotes the
same as double quotes. Creating strings is as simple as assigning a value to
a variable. For example −
var1 = 'Hello World!'
var2 = "Python Programming"
Accessing Values in Strings
Python does not support a character type; these are treated as strings of
length one, thus also considered a substring.
To access substrings, use the square brackets for slicing along with the
index or indices to obtain your substring. For example −
var1 = 'Hello World!'
var2 = "Python Programming"
print "var1[0]: ", var1[0]
print "var2[1:5]: ", var2[1:5]
Opera Description Example
tor

+ Concatenation - Adds values on a + b will give HelloPython


either side of the operator

* Repetition - Creates new strings, a*2 will give –HelloHello


concatenating multiple copies of
the same string

[] Slice - Gives the character from a[1] will give e


the given index

[:] Range Slice - Gives the characters a[1:4] will give ell
from the given range
THANK YOU

You might also like