0% found this document useful (0 votes)
303 views

R20 Python Programming-2021-02-08 PDF

The document describes an Object Oriented Programming course in Python. It outlines 5 units that will be covered: introduction to Python, operators and expressions, data structures, modules, and object oriented programming. It also lists course objectives like acquiring Python programming skills and OOP features, and course outcomes like applying concepts to real problems. The lab portion involves exercises to practice various Python concepts like control flow, functions, data structures, files, modules, and object oriented programming.

Uploaded by

PRABHAKAR K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
303 views

R20 Python Programming-2021-02-08 PDF

The document describes an Object Oriented Programming course in Python. It outlines 5 units that will be covered: introduction to Python, operators and expressions, data structures, modules, and object oriented programming. It also lists course objectives like acquiring Python programming skills and OOP features, and course outcomes like applying concepts to real problems. The lab portion involves exercises to practice various Python concepts like control flow, functions, data structures, files, modules, and object oriented programming.

Uploaded by

PRABHAKAR K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

OBJECT ORIENTED PROGRAMMINGS WITH PYTHON

II Semester: CSE/AI & ML /IT


Course Objectives:

I. Acquire programming skills in core Python.


II. Acquire Object-Oriented Programming features implementation in Python.
III. To understand data structures in Python
IV. Develop the ability to use Operating System functions in python applications
V. Able to use exception handling in python programs
Course Outcomes:
CO1: Recognize core programming basics and program design with functions using Python
programming language.
CO2: Interpret the high-performance programs designed to strengthen the practical expertise.
CO3: Develop applications for real time problems by applying python data structure concepts.
CO4: Understand and apply the concepts of packages, handling, multithreading and socket
programming.
CO5: Analyze the importance of object-oriented programming over structured programming.

UNIT – I:
Introduction to Python: Features of Python, History of Python, Need of Python Programming,
Applications Basics of Python Programming Using the REPL(Shell), Running Python Scripts,
Variables, Assignment, Keywords, Input-Output, Indentation.
Data types: Integers, Strings, Booleans.

UNIT – II:
Operators and Expressions: Types - Operators- Arithmetic Operators, Comparison (Relational)
Operators, Assignment Operators, Logical Operators, Bitwise Operators, Membership Operators,
Identity Operators, Expressions and order of evaluations
Control Flow: if, if-elif-else, for, while, break, continue, pass

UNIT – III:
Data Structures: Lists - Operations, Slicing, Methods; Tuples, Sets, Dictionaries, Sequences.
Comprehensions.
Functions: Defining Functions, Calling Functions, Passing Arguments, Keyword Arguments,
Default Arguments, Variable-length arguments, Anonymous Functions, Fruitful Functions (Function
Returning Values), Scope of the Variables in a Function - Global and Local Variables.

UNIT – IV:
Modules: Creating modules, import statement, from. Import statement, name spacing,
Python packages: Introduction to PIP, Installing Packages via PIP, Using Python Packages.
Object Oriented Programming in Python: Classes, 'self-variable', Methods, Constructor
Method, Inheritance, Overriding Methods, Data hiding,

UNIT – V:
Error and Exceptions: Difference between an error and Exception, Handling Exception, try
except block, Raising Exceptions, User Defined Exceptions
Brief Tour of the Standard Library: Operating System Interface - String Pattern Matching,
Mathematics, Internet Access, Dates and Times, Data Compression, Multithreading, GUI
Programming, Turtle Graphics

Text Books:
1. Learning Python, Mark Lutz, Orielly
2. Python Programming: A Modern Approach, Vamsi Kurama, Pearson
3. R Nageswara Rao, “Core Python Programming”, Dream tech press, 2017 Edition
4. Dusty Philips, “Python 3 Object Oriented Programming”, PACKT Publishing, 2nd Edition,
2015
Reference Books:
1. Think Python, Allen Downey, Green Tea Press
2. Core Python Programming, W.Chun, Pearson.
3. Introduction to Python, Kenneth A. Lambert, Cengage
4. Michael H.Goldwasser, David Letscher, “Object Oriented Programming in Python”,
Prentice Hall, 1st Edition, 2007.
Web References:
1. https://realpython.com/python3-object-oriented-programming/
2. https://python.swaroopch.com/oop.html
3. https://python-textbok.readthedocs.io/en/1.0/Object_Oriented_Programming.html
4. https://www.programiz.com/python-programming
Object Oriented Programming through Python LAB

COURSE OUTCOMES:
CO1: Apply core programming basics and program design with functions using Python
programming language.
CO2: Interpret the high-performance programs designed to strengthen the practical expertise.
CO3: Develop applications for real time problems by applying python data structure concepts.
CO4: Test and apply the concepts of packages, handling, multithreading and socket programming.
CO5: Divide the importance of object-oriented programming over structured programming.

Exercise 1 - Basics
a) Running instructions in Interactive interpreter and a Python Script
b) Write a program to purposefully raise Indentation Error and Correct it

Exercise 2 - Operations
a) Write a program to compute distance between two points taking input from the user.
b) Write a program add.py that takes 2 numbers as command line arguments and prints its sum.

Exercise - 3 Control Flow


a) Write a Program for checking whether the given number is a even number or not.
b) Using a for loop, write a program that prints out the decimal equivalents of 1/2, 1/3, 1/4, . . .1/10
c) Write a program using a for loop that loops over a sequence. What is sequence?
d) Write a program using a while loop that asks the user for a number, and prints a countdown from
that number to zero.

Exercise 4 - Control Flow - Continued


a) Find the sum of all the primes below two million. Each new term in the Fibonacci sequence is
generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
b) By considering the terms in the Fibonacci sequence whose values do not exceed four million,
find the sum of the even-valued terms.

Exercise - 5 - DS
a) Write a program to count the numbers of characters in the string and store them in a dictionary
data structure
b) Write a program to use split and join methods in the string and trace a birthday with a dictionary
data structure.

Exercise - 6 DS - Continued
a) Write a program combine lists that combines these lists into a dictionary.
b) Write a program to count frequency of characters in a given file. Can you use character
frequency to tell whether the given file is a Python program file, C program file or a text file?

Exercise - 7 Files
a) Write a program to print each line of a file in reverse order.
b) Write a program to compute the number of characters, words and lines in a file.

Exercise - 8 Functions
a) Write a function ball collide that takes two balls as parameters and computes if they are colliding.
Your function should return a Boolean representing whether or not the balls are colliding.
Hint: Represent a ball on a plane as a tuple of (x, y, r), r being the radius
If (distance between two balls centers) <= (sum of their radii) then (they are colliding)
b) Find mean, median, mode for the given set of numbers in a list.
Exercise - 9 Functions - Continued
a) Write a function nearly equal to test whether two strings are nearly equal. Two strings a and b are
nearly equal when a can be generated by a single mutation on b.
b) Write a function dups to find all duplicates in the list.
c) Write a function unique to find all the unique elements of a list.

Exercise - 10 - Functions - Problem Solving


a) Write a function cumulative product to compute cumulative product of a list of numbers.
b) Write a function reverse to reverse a list. Without using the reverse function.
c) Write function to compute gcd, lcm of two numbers. Each function shouldn’t exceed one line.

Exercise 11 - Multi-D Lists


a) Write a program that defines a matrix and prints
b) Write a program to perform addition of two square matrices
c) Write a program to perform multiplication of two square matrices

Exercise - 12 - Modules
a) Install packages requests, flask and explore them. using (pip)
b) Write a script that imports requests and fetch content from the page.
c) Write a simple script that serves a simple HTTP Response and a simple HTML Page

Exercise - 13 OOP
a) Class variables and instance variable and illustration of the self-variable
i) Robot ii) ATM Machine

Exercise - 14 GUI, Graphics


a) Write a GUI for an Expression Calculator using tk
b) Write a program to implement the following figures using turtle.

You might also like