R24_PythonProgramming_Syllabus
R24_PythonProgramming_Syllabus
Pre-Requisite: None
Mapping of Course Outcomes with Program Outcomes & Program Specific Outcomes
POs PSOs
CO 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
CO1 3 3 3 - 3 - - 2 - 2 - 3 3 3 3
CO2 3 3 3 - 3 - - 2 - 2 - 3 3 3 3
CO3 3 3 3 - 3 - - 2 - 2 - 3 3 3 3
CO4 3 3 3 - 3 - - 2 - 2 - 3 3 3 3
UNIT-1 (12Hours)
Introduction: Overview, History of Python, Python Features, Environment Setup.
Variables, expressions, and statements: values and types, variables, names and keywords,
statements, operators and operands, expressions, order of operations, modulus operator,
string operations, asking the user for input, comments, choosing mnemonic variable names.
Conditional execution: Boolean expressions, logical operators, conditional execution,
Alternative execution, chained conditionals, nested conditionals, catching exceptions using
try and except, short-circuit evaluation of logical expressions.
Functions: function calls, built-in functions, type conversion functions, random numbers, math
functions, adding new functions, definitions and uses, flow of execution, parameters
and arguments, fruitful functions and void functions.
UNIT-2 (12 Hours)
Iteration: updating variables, the while statement, infinite loops and break, finishing
iterations with continue, definite loops using for, loop patterns.
Strings: string is a sequence, getting the length of a string using len, traversal through a
string with a loop, string slices, strings are immutable, looping and counting, the in operator,
string comparison, string methods, parsing strings, format operator.
Files I/O: persistence, opening files, text files and lines, reading files, searching through a file,
letting the user choose the file name, using try except and open, writing files.
UNIT-3 (12 Hours)
Lists: a list is a sequence, lists are mutable, traversing, operations, slices, methods, deleting
elements, functions, strings, parsing lines, objects and values, aliasing, arguments.
Dictionaries: dictionary as a set of counters, dictionaries and files, looping and dictionaries,
advanced text parsing.
Tuples: tuples are immutable, comparing tuples, tuple assignment, dictionaries and tuples,
multiple assignment with dictionaries, the most common words, using tuples as keys in
dictionaries, sequences.
UNIT-4 (12 Hours)
Object-Oriented Programming: Managing Larger Programs, Using Objects, starting with
Programs, Subdividing a Problem–Encapsulation, First Python Object, Classes as Types,
Object Lifecycle, Many Instances, Inheritance.
Using Databases and SQL: Database concepts, Database Browser for SQLite, creating a
database table, Structured Query Language summary, Basic data modeling, Programming with
multiple tables, three kinds of keys, Using JOIN to retrieve data.
LIST OFEXPERIMENTS
1. Write a python program to check if the number is positive or negative or zero and display
an appropriate message.
2. Write a python program to take a string from user and count number of vowels
Present and percentage of vowels in it.
3. Write a python program to find the most frequent words in a text file.
4. Write a python program to find the sum of first n natural numbers.
5. Write a python program to find the numbers which are divisible by 7 and multiple of 5
between 1500 and 2700.
6. Write a python program to solve quadratic equation.
7. Create a program that ask the user for a number and then prints out a list of all the
divisors of that number.
8. Write a python program to find HCF or GCD.
9. Write a python program to find LCM.
10. Write a python program to construct the following pattern, using a nested loop number.
1
22
333
4444
55555
666666
11. Write a python program to sort the given words in alphabetic order.
12. Write a python function to create the HTML string with tags around the word(s).
13. Write a python program to reverse words in a string.
14. Write a python program to strip a set of characters from a string.
15. Write a python function to find the maximum and minimum of a list of numbers.
16. Write a python program to find the square root.
17. Write a python program to convert decimal to binary using recursion.
18. Write a python recursive function to find the factorial of a given number.
19. Write a python program to find the longest word in each line of given file.
20. Write a Python program to combine each line from first file with the corresponding line
in second file.
21. Write a python program to read a random line from a file.
23. Write a python program to split a list every Nth element.
Sample list : ['a', 'b', 'c', 'd', 'e', 'f ', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n']
Expected output : [['a', 'd', 'g', 'j', 'm'] , ['b', 'e', 'h', 'k', 'n'] , ['c', 'f', 'i', 'l']]
24. Write a python program to compute the similarity between two lists.
Sample data:
["red", "orange", "green", "blue", "white"], ["black", "yellow", "green", "blue"]
Expected output:
Color1-Color2: ['white', 'orange', 'red']
Color2-Color1: ['black', 'yellow']
25. Write a python program to replace the last element in a list with another list.
Sample data : [1, 3, 5, 7, 9, 10 ] , [2, 4, 6, 8 ]
Expected output : [1, 3, 5, 7, 9, 2, 4, 6, 8]
26. Write a python program to find the repeated items of a tuple.
27. Write a python program to convert a list with duplicates to a tuple without duplicates.
28. Write a python program to reverse the elements of a tuple.
29. Write a python program to replace last value of tuples in a list.
Sample list : [(10, 20, 40) , (40, 50, 60) , (70, 80, 90)]
Expected output : [(10, 20, 100) , (40, 50, 100) , (70, 80, 100)]
31. Write a python program to combine two dictionaries by adding values for common
keys.
d1 = {'a' : 100, 'b' : 200, 'c' : 300}
d2 = {'a' : 300, 'b' : 200, 'd' : 400}
Sample output : {'a' : 400, 'b' : 400, 'd' : 400, 'c' : 300}
33. Write a python program to create and display all combinations of letters, selecting each
letter from a different key in a dictionary.
Sample data: {'1' : ['a', 'b'], '2' : ['c', 'd']}
Expected output:
a
c
a
d
b
c
b
d
34. Write a python program to get the top three items in a shop.
Sample data:
{'item1' : 45.50, 'item2' : 35, 'item3' : 41.30, 'item4' : 55, 'item5' : 24}
Expected output:
item4 55 item1 45.5 item3 41.3
35. Write a python program to match both key values in two dictionaries.
Sample dictionary:{'key1' : 1,'key2' : 3, 'key3' : 2}, {'key1' : 1,'key2' : 2}
Expected output: key1: 1 is present in both x and y
36. Write a python class named Rectangle constructed by a length and width and a method
which will compute the area of a rectangle.
37. Write a python class named Circle constructed by a radius and two methods which will
compute area and perimeter of a circle.
38. Write a python program to create a single linked list using classes.
39. Write a python program to create a FIFO (queue) using classes.
40. Predict the output of the following python programs and write the justification.
classX(object):
def__init(self,a):
self.num=a
def doubleup(self):
self.num*=2
classY(X):
def__init(self,a):
X.init(self,a)
def tripleup(self):
self.num*=3
obj=Y(4)
print(obj.num)
obj.doubleup()
print(obj.num)
obj.tripleup()
print(obj.num)
41. Predict the output of the following python programs and write the justification.
#Base or Superclass
Class Person(object):
def__init(self,name):
self.name=name
def getName(self):
return self.name
def isEmployee(self):
return False
def getID(self):
return self.empID
# Driver code
emp=Employee("Geek1", "E101")
print(emp.getName( ), emp.isEmployee( ), emp.getID( ))
42. Create an employees database with the following attributes and insert rows.
employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary,
commission_pct, manager_id, department_id
43. Write a query to get the highest, lowest, sum and average salary of all employees.
44. Write a query to get the average salary for all departments employee more than 10
employees.
45. Write a query to find the names (first_name, last_name), the salary of the employees
whose salary is greater than the average salary.
46. Write a query to get nth max salaries of employees.
Text Books: 1. A Python Book: Beginning Python, Advanced Python, and Python
Exercises, Dave Kuhlman, Open Source MIT License.
2. Python for Data Analysis, Wes McKinney, O’ Reilly.
References: 1. Python Data Science Handbook-Essential Tools for Working with
2. Data Science from Scratch, JoelGrus, O’Reilly.