Python Syllabus
Python Syllabus
Python Syllabus
Teaching Scheme
L T P Credit
3 0 2 4
Pre-requisites:
Python is a next generation multi-purpose programming language that allows different users to create
applications of various domains. Students will be able to learn primary fundamentals of python programming
and potential of python to achieve modern computing requirements.
Course Outcomes:
CO1: Understand fundamental Python syntax and semantics and be fluent in the use of Python control flow
statements.
CO2: Apply functions, modules and string handling in Python to solve problems.
CO3: Express proficiency in the handling of strings and functions using string manipulation, string slicing and
formatting functions.
CO4: Apply the concept of object-oriented approach for solving real world problems.
CO5: Develop Console application, Database application, and Machine Learning application in Python.
Syllabus:
Unit 1:
Introduction:
The Programming Cycle for Python, Python IDE, Interacting with Python Programs, Working with Jupyter
notebook, Elements of Python, Type Conversion.
Basics: Expressions, Assignment Statement, Arithmetic Operators, Operator Precedence, Boolean Expression.
[No. Of Hours: 8]
Unit 2:
Conditionals:
Conditional statement in Python (if-else statement, its working and execution), Nested-if statement and Elif
statement in Python, Expression Evaluation & Float Representation.
Loops: Purpose and working of loops , While loop including its working, For Loop , Nested Loops , Break and
Continue.
Function: Parts of A Function , Execution of A Function , Keyword and Default Arguments ,Scope Rules.
Iterators & Recursion: Recursive Fibonacci , Tower Of Hanoi
Strings : Length of the string and perform Concatenation and Repeat operations in it. Indexing and Slicing of
Strings.
[No. Of Hours: 12]
Unit 3:
Python Data Structure:
Tuples, Unpacking Sequences, Lists, Mutable Sequences, List Comprehension, Sets, Dictionaries
Classes and Objects: Introduction, classes and objects, class method and self argument, init() method, class
and object variables, del() method, other special methods, public and private data members, private methods,
calling a class method from another class method, built-in class attributes, garbage collection, class and static
methods
Inheritance: Introduction, inheriting classes in python, types of inheritance, composition/containership/complex
objects, abstract classes and interfaces, Meta class.
[No. Of Hours: 11]
Unit 4:
File I/O:
File input and output operations in Python Programming
Modules : Introduction , Importing Modules , Abstract Data Types : Abstract data types and ADT interface in
Python Programming.
Error and Exception Handling: Introduction to errors and exceptions, handling exceptions, multiple except
blocks, multiple exceptions in a single block, except block without exception, the else clause, raising
exceptions, built-in and user-defined exceptions, the finally block.
[No. Of Hours: 9]
Practical/Laboratory Content:
2. Basics
a) Running instructions in Interactive interpreter and a Python Script
b) Write a program to purposefully raise Indentation Error and Correct it
3. 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.
4. 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.
d) Write a program using a while loop that asks the user for a number, and prints a countdown from
that number to zero.
e) Find the sum of all the primes below two million.
f) 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,…
g) By considering the terms in the Fibonacci sequence whose values do not exceed four million, find
the sum of the even-valued terms.
5. Dictionary
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.
c) Write a program combining lists and then combine these lists into a dictionary.
6. Files
a) 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?
b) Write a program to print each line of a file in reverse order.
c) Write a program to compute the number of characters, words and lines in a file.
7. 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.
8. 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.
11. Modules
a) Install packages requests, flask and explore them. using (pip).
b) Write a script that imports requests and fetches content from the page. Eg. (Wiki).
c) Write a simple script that serves a simple HTTP Response and a simple HTML Page.
12. OOP
a) Implement function overloading with different function signatures.
b) Implement concepts of class, instances and inheritance.
13. Testing
c) Write a test-case to check the function even_numbers which return True on passing a list of all
even numbers.
d) Write a test-case to check the function reverse string which returns the reversed string.
Note: The program list is only for reference purposes; the concerned subject professor may modify it as per the
need.
Required Readings:
Reference Books:
1. Allen B. Downey, (2016). Think Python: How to Think Like a Computer Scientist, 2nd edition. Updated for
Python 3, Shroff/O‘Reilly Publishers.
2. Guido van Rossum and Fred L. Drake Jr (2011).An Introduction to Python. Network Theory Ltd.
3.John V Guttag (2013). Introduction to Computation and Programming Using Python, Revised and expanded
Edition. MIT Press.
4.Robert Sedgewick, Kevin Wayne, Robert Dondero (2016).Introduction to Programming in Python: An
Interdisciplinary Approach. Pearson India Education Services Pvt. Ltd.
5.Timothy A. Budd (2015). Exploring Python. Mc-Graw Hill Education (India) Private Ltd.
6.Kenneth A. Lambert (2012). Fundamentals of Python: First Programs. CENGAGE Learning.
7.Charles Dierbach (2013). Introduction to Computer Science using Python: A Computational Problem Solving
Focus. Wiley India Edition.
8.Paul Gries, Jennifer Campbell and Jason Montojo (2013).Practical Programming: An Introduction to
Computer Science using Python , Second edition. Pragmatic Programmers, LLC.