4.Advanced Programming Using Python-2
4.Advanced Programming Using Python-2
Prerequisites: Knowledge of programming in any language like C, C++ and basic statistical
knowledge.
Text Book:
1. Python For Everybody: Exploring Data In Python 3, Charles R.Severance,
Reference Book:
1. Data wrangling using python by Jacqueline Kazil, Katharine Jarmul
2. Introduction to Computer Science using Python, Charles/ Wiley
3. Learn Python the Hard Way, Zed A.Shaw, Pearson , 2018
4. Python Crash Course: A Hands-on, Project-Based Introduction to Programming
5. Python Cookbook by David B. Brain K. Jones / Shroff / O'reilly Publisher
6. Head First Python by Paul Barry / Shroff / O'reilly Publisher
7. Beginning Programming with Python for Dummies by John Paul Muller / Wiley
Note:
• Each session mentioned is of 2 hours’ duration for theory only. Lab assignments are
indicatives; faculty shall provide adequate assignments for better practice.
• Faculties are advised to give at least one lab assignment as end-to-end application
Session 1, 2 & 3:
Lecture
Installing Python
Introduction to Python
Introduction to different Python IDE
Basic Syntax
Data Types, Variables, Operators, Input/output
Declaring variable, data types in programs
Your First Python Program
PG-DAI Page 1 of 9
ACTS, Pune
Q.2. Modify the program above using a while loop so it prints out all of the factorial values that are
less than 2 billion. (You should be able to do this without looking at the output of the previous
exercise.)
Session 4
Lecture
Pass, Strings and
Tuples
Accessing Strings
Basic Operations
Assigning Multiple Values at Once
Formatting Strings
String slices,
Historical Note on String Methods
Lab Assignments:
Q.1. Write a program that asks the user how many days are in a particular month, and what day of
the week the month begins on (0 for Monday, 1 for Tuesday, etc), and then prints a calendar for
that month. For example, here is the output for a 30-day month that begins on day 4 (Thursday): S
M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
PG-DAI Page 2 of 9
ACTS, Pune
Session 5
Lecture
Dictionaries
Introducing Dictionaries
Defining Dictionaries
Modifying Dictionaries
Deleting Items from Dictionaries
Lab Assignments:
Q. 1. In cryptography, a Caesar cipher is a very simple encryption techniques in which each letter in
the plain text is replaced by a letter some fixed number of positions down the alphabet. For example,
with a shift of 3, A would be replaced by D, B would become E, and so on. The method is named
after Julius Caesar, who used it to communicate with his generals. ROT-13 ("rotate by 13 places")
is a widely used example of a Caesar cipher where the shift is 13. In Python, the key for ROT-13
may be represented by means of the following dictionary:
key = {'a':'n', 'b':'o', 'c':'p', 'd':'q', 'e':'r', 'f':'s', 'g':'t', 'h':'u', 'i':'v', 'j':'w', 'k':'x', 'l':'y', 'm':'z', 'n':'a', 'o':'b',
'p':'c', 'q':'d', 'r':'e', 's':'f', 't':'g', 'u':'h', 'v':'i', 'w':'j', 'x':'k', 'y':'l', 'z':'m', 'A':'N', 'B':'O', 'C':'P', 'D':'Q', 'E':'R',
'F':'S', 'G':'T', 'H':'U', 'I':'V', 'J':'W', 'K':'X', 'L':'Y', 'M':'Z', 'N':'A', 'O':'B', 'P':'C', 'Q':'D', 'R':'E', 'S':'F',
'T':'G', 'U':'H', 'V':'I', 'W':'J', 'X':'K', 'Y':'L', 'Z':'M'}
Your task in this exercise is to implement an encoder/decoder of ROT-13. Once you're done, you
will be able to read the following secret message:
Note that since English has 26 characters, your ROT-13 program will be able to both encode and
decode texts written in English.
Session 6 & 7
Lecture
Working with Lists
Introducing Lists
Defining Lists
Declare, assign and retrieve values from Lists
Accessing list o Operations in Lists
Adding Elements to Lists
Searching Lists
PG-DAI Page 3 of 9
ACTS, Pune
Lab Assignments:
Session 8 & 9
Lecture
Function and Methods
Defining a function
Calling a function
Types of functions
Function Arguments
Anonymous functions
Global and local variables
Using Optional and Named Arguments
Using type, str, dir, and Other Built-In Functions
Regular Expressions Using python
Lab Assignments:
Q1.Given a dictionary of students and their favourite colours:
people={'Arham':'Blue','Lisa':'Yellow',''Vinod:'Purple','Jenny':'Pink'}
1. Find out how many students are in the list
2. Change Lisa’s favourite colour
3. Remove 'Jenny' and her favourite colour
4. Sort and print students and their favourite colours alphabetically by name
Write a function translate() that will translate a text into "rövarspråket" (Swedish for "robber's
language"). That is, double every consonant and place an occurrence of "o" in between. For
example, translate("this is fun") should return the string "tothohisosisosfofunon".
Q.2. Write a function filter_long_words() that takes a list of words and an integer n and returns the
list of words that are longer than n
PG-DAI Page 4 of 9
ACTS, Pune
Session 10
Lecture
Working with Tuples
Introducing Tuples
Accessing tuples
Operations
Lab Assignments:
Q.1. Swap the following two tuples
tuple1 = (11, 22) tuple2 =
(99, 88) Expected output:
tuple1 = (99, 88)
tuple2 = (11, 22)
Lab Assignments:
Q.1. Write a python program using Object oriented programming for the following:
Accept data in following format for salaried employee objects and contract employee employee
objects
Salaried employee
PG-DAI Page 5 of 9
ACTS, Pune
contractemployee
12,esha,insurance,Manager,12,1000.00
13,revati,ux,ux designer,111,1500.00
store employee data in a list and perform the following function on it. a)
Add new Employee
b) Delete employee
c) Modify salary of employee
d) Search employee
e) Calculate Salary of Employee
f) Display All
g) Exit ---
Formula for calculate Sal for contract Emp = hrs_worked * hourly charges
Session 14 & 15
Lecture
Operations Exception
Exception Handling
Except clause
Try finally clause
User Defined Exceptions
PG-DAI Page 6 of 9
ACTS, Pune
Session 16
Lecture
Libraries and Functionality Programming
Debugging basics
Logging using Python
Lab Assignments:
Lab Assignments:
Q.1.Numpy assignments - accept 20 numbers from user and store it in a list1, list2, list3, list4 (5
numbers in each list)
Then convert these list into 2 numpy array (list1, list2 in array1 and list3 and list4 in array2) and
find member wise addition, multiplication, subtraction also find exponential of first array
PG-DAI Page 7 of 9
ACTS, Pune
Session 20 & 21
Lecture
Working with matplotlib seaborn
Working with ggplot, plotly
Lab Assignments:
Session 22
Lecture
DB’s in Python
Working on DB using Python
Lab Assignments:
Q1. Create user table in database to store username, address, mobile and email. Add 10 records
in the table Write a python program to accept username and address from user check whether user
exists in user table. If exists, then display details of user on the screen and if user not found then
accept user details and store it in the table
Session 23 & 24
Lecture
Web based frameworks: Flask and Django
Lab Assignments:
PG-DAI Page 8 of 9
ACTS, Pune
Lab Assignments:
PG-DAI Page 9 of 9