211cse1401 Python Programming
211cse1401 Python Programming
COURSE OBJECTIVES:
• To learn how to use lists, tuples, and dictionaries in Python programs.
• To learn how to use indexing and slicing to access data in Python programs.
COURSE OUTCOMES:
CO1: Understand the constructs and concepts of a programming language
CO2: Apply Python data structures for problem solving and programming
CO3: Implement user defined python functions and build an efficient program leveraging
modules
CO4: Create python programs to handle file I/O and exceptions, and solve problems with
Object Oriented Concepts
21
MAPPING OF COURSE OUTCOMES WITH PO, PSO:
PO’S
1 2 3 4 5 6 7 8 9 10 11 12
CO1 S S S
CO2 S S S
CO3 S M M M
CO4 S S S S S
CO5 S M M S M S
22
ing at Beginning or End, Match Objects, Substituting, Splitting a String, Compiling Regular
Expressions, Flags.
Numerical Analysis & Plotting: Numpy – Overview, Setup, Datatypes, Basic Op- erators,
Indexing, Broadcasting, Matrix Operators. Matplotlib-Overview, Setup, Basic plots,
Customizing plots, Subplots, 3D plots.
Data Processing with Pandas: Pandas – Overview, Setup, Data Structures, Indexing
& Selecting Data, groupby Operations, Reshaping data.
X Component
• Competitive coding using Core Python – Practical Assignments and Hacker-
rank challenges
23
Lists, Tuples Explicit Hands-on ses-
Teaching sion for Lists
and Tuples
- methods
and functions
Hackerrank –
Problem Solving
Challenge
Sets, Dictionary Explicit Hands-on ses- Create solutions
Week 3
Teaching sion for Sets for complex
and Dictionary problem
- methods and statements
functions leveraging
Comprehension Explicit List Comprehen- Python Data
Teaching sion, Dictionary structures
Comprehen-
sion, Lambda,
Hackerrank –
Problem Solving
Challenge
Functions Explicit Getting started Apply
Week 4
Teaching with function the buit-in and
oriented pro- user defined
gramming functions to
create efficient
programs lever-
aging Python
modules.
Modules Explicit Modular Pro-
Teaching gramming,
Built-in Mod-
ules
Exceptions Explicit Practicing pro- Get data from
Week 5
Teaching grams that are sensors through
robust against Raspberry Pi,
exceptional in- with
puts appropriate
Input/Output Explicit Getting data Exceptional
Teaching out from Excel, Handling
Notepad
Week 6 Object Oriented Explicit Attribute Tree Create Object
Programming: Teaching Construction Oriented Solu-
Class Statement Specializing tion for solving
Methods Inheri- Inherited Meth- application ori-
tance ods, Class ented problems
Interface Tech-
niques Abstract
Super Classes
24
Regular Expres- Explicit Practicing Validate data
Week 7
sions, Simple Teaching regular using RegExp
Character expression rules package for
Matches, Spe- for different realtime inputs,
cial Characters, problem from integrated
Character scenarios environment
Classes, Quan-
tifiers, The Dot
Character
Greedy Matches, Explicit
Grouping, Teaching
Matching at
Beginning or
End, Match
Objects, Substi-
tuting, Splitting
a String, Com-
piling Regular
Expressions,
Flags.
Week 8 Numerical Anal- Explicit Performing op- Perform com-
ysis, Datatypes, Teaching erations on data plex mathetical
Basic Opera- frames obtained operations lever-
tors, Indexing, from real time aging Numpy
Broadcasting, datasets
Matrix Opera-
tors.
Week 9 Plotting, Basic Explicit Practicing data Perform data
plots, Customiz- Teaching plots for Real visualization on
ing plots, Sub- time datasets streaming data
plots, 3D plots
Week 10 Data Processing, Explicit Working with Process data
Data Structures, Teaching data processing from benchmark
Indexing & operations using sites using Pan-
Selecting Data, Pandas das, Numpy,
groupby Opera- Matplotlib
tions, Reshaping
data.
25
Week 11 Tkinter: Tk Explicit Tkinter Pro- Create a
Widget, Button Teaching gramming for UI well-defined user
Widgets, Entry Snips interface, based
Widgets, Text on the problem
Widgets, Check- requirement
button Widgets, (GUI
Radiobutton Development)
Widgets, List-
box Widgets,
Frame Widgets,
Menu Widgets,
Toplevel Wid-
gets, Dialogs
Week 12 Developing User Explicit Efficient UI
Interface with Teaching Development
OOP using Tkinter
and OOP
Week 13 Desktop App Project Problem Identification and Backend details
Development Based
Learning
Week 14 Creating own Project Pip, PyPi, Licence Reception
Python Pack- Based
ages Learning
Week 15 UI Development Project UI Development for Integrated Application
Based
Learning
EXPERIMENTS:
1. Let d(n) be defined as the sum of proper divisors of n (numbers less than n which
divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each
of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and
110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so
d(284) = 220.
Find the count of the matching proper divisors of the given amicable number
2. We come across varying magic numbers or so called occult numbers. There arevery
few numbers in having a particular property. The so called occult number inour
scenario is the number, whose individual digits’ factorial sum will give back the same
number.
For instance: 40585 = 4! + 0! + 5! + 8! + 5! = 40585
Calculate the number of occult numbers in the less than a particular value ’alpha’
Alpha will be given in the input
26
3. A positive integer, n, is factorised into prime factors. We define f(n) to be the
product when each prime factor is replaced with 2. In addition we define f(1)=1.
For example, 90=2*3*3*5, then replacing the primes, 2*2*2*2=16, hence f(90)=16.
Calculate f(n), for the given n
4. 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, ...
By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum of the even-valued terms upto the given V terms series.
5. Namonical charge is a value that is calculated by inputting the name of the person.
The charge is calculated by first coverting the characters in the name to its corre-
sponding alphabetical position and then accumulating a sum based on the following
rules:
(i) if the number is even, take factorial of it
(ii) if the number is odd, take the square root of the number
The accumulated sum is returned as the Namonical charge of the given name
Eg.
name = ”abcd”
a - 1 (odd, take square root)
b - 2 (even, take factorial)
c - 3 (odd, take square root)
d - 4 (even, take factorial)
Namonical charge = sqrt(1) + factorial (2) + sqrt(3) + factorial(4) = 28.732
Note: Round the output to three decimal digits
6. For a positive integer n, define f(n) to be the number of non-empty substrings of n that
are divisible by 3. For example, the string ”2573” has 10 non-empty substrings, three of
which represent numbers that are divisible by 3, namely 57, 573 and 3. So f(2573)=3.
If f(n) is divisible by 3 then we say that n is 3-like.
If the given number is 3-like, print ’yes’, otherwise print ’no’
27
5 2 6 3 9 1 7 // The array (index starts from zero)
2 // Start range
5 // end range
Output:
5236917
9. Convert the given word into magnet word. Magnet word is a word which will have
a property.
Each character of the word will be assigned index starting from 1.
Alphabets in English will be numbered from index 1.
Reverse of the multiplied indices of the character in string and alphabers, mod 26
gives the corresponding magnetic character.
Replace all the characters in the given string with its magnetic character, resulting
in magnetic word.
Note: If a character is changed to magnetic once, all its subsequents appearances
will have the same magnetic character.
(space character remains untouched)
The elements between the range 2 and 5-1 are sorted
10. Ak gave a challenge to Vj. Ak gave a decimal number N.
Vj needs to find the product of unique critical digits of the number N.
Critical digits are those digits which are divisible by X.
The value X is 2, if the number of unique even numbers is greater than those of
unique odd numbers, else, the value of X is 1.
Help Vj to crack the challenge.
Eg. N = 123564.2654916465
If the count of numbers to the left of . (dot) is greater than the count of numbers
to the right, then . (dot) is considered as even number. Else . (dot) is consideredas
odd number. In above case, . (dot) is considered as odd number.
28
out of its 11 field players. Team should contain minimum 4 aggressive players Note: An
all-rounder can be accounted as either batsmen or bowler
Help team RSK management to finds its best 11-squad to win the trophy. Prove
to the management by selecting a optimal team with highest cumulative x-factor
value
TEXT BOOK(S):
1. Mark Lutz, “Learning Python”, Fifth Edition, O,Reilly, 2018
REFERENCES:
1. Charles Severance, 2016, Python for everybody: exploring data in Python 3
29