Bsc. I.T.

Python Programming Syllabus

UnitDetails
I Introduction: The Python Programming Language, History, features, Installing Python, Running Python program, Debugging : Syntax Errors, Runtime Errors, Semantic Errors, Experimental Debugging, Formal and Natural Languages, The Difference Between Brackets, Braces, and Parentheses

Variables and Expressions: Values and Types, Variables, Variable Names and Keywords, Type conversion, Operators and Operands, Expressions, Interactive Mode and Script Mode, Order of Operations.

Conditional Statements: if, if-else, nested if –else

Looping: for, while, nested loops

Control statements: Terminating loops, skipping specific conditions
II Functions: Function Calls, Type Conversion Functions, Math Functions, Composition, Adding New Functions, Definitions and Uses, Flow of Execution, Parameters and Arguments, Variables and Parameters Are Local, Stack Diagrams, Fruitful Functions and Void Functions, Why Functions? Importing with from, Return Values, Incremental Development, Composition, Boolean Functions, More Recursion, Leap of Faith, Checking Types

Strings: A String Is a Sequence, Traversal with a for Loop, String Slices, Strings Are Immutable, Searching, Looping and Counting, String Methods, The in Operator, String Comparison, String Operations.
III Lists: Values and Accessing Elements, Lists are mutable, traversing a List, Deleting elements from List, Built-in List Operators, Concatenation, Repetition, In Operator, Built-in List functions and methods

Tuples and Dictionaries: Tuples, Accessing values in Tuples, Tuple Assignment, Tuples as return values, Variable-length argument tuples, Basic tuples operations, Concatenation, Repetition, in Operator, Iteration, Built-in Tuple Functions
Creating a Dictionary, Accessing Values in a dictionary, Updating Dictionary, Deleting Elements from Dictionary, Properties of Dictionary keys, Operations in Dictionary, Built-In Dictionary Functions, Built-in Dictionary Methods

Files: Text Files, The File Object Attributes, Directories

Exceptions: Built-in Exceptions, Handling Exceptions, Exception with Arguments, User-defined Exceptions
IV Regular Expressions: Concept of regular expression, various types of regular expressions, using match function.

Classes and Objects: Overview of OOP (Object Oriented Programming), Class Definition, Creating Objects, Instances as Arguments, Instances as return values, Built-in Class Attributes, Inheritance, Method Overriding, Data Encapsulation, Data Hiding

Multithreaded Programming: Thread Module, creating a thread, synchronizing threads, multithreaded priority queue

Modules: Importing module, Creating and exploring modules, Math module, Random module, Time module
V Creating the GUI Form and Adding Widgets:
Widgets:
Button, Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menubutton, Menu, Message, Radiobutton, Scale, Scrollbar, text, Toplevel, Spinbox, PanedWindow, LabelFrame, tkMessagebox. Handling Standard attributes and Properties of Widgets.

Layout Management: Designing GUI applications with proper Layout Management features.

Look and Feel Customization: Designing GUI applications with proper Layout Management features.

Storing Data in Our MySQL Database via Our GUI: Connecting to a MySQL database from Python, Configuring the MySQL connection, Designing the Python GUI database, Using the INSERT command, Using the UPDATE command, Using the DELETE command, Storing and retrieving data from MySQL database.

Python Programming Practicals

Practical NoDetails
1 Write the program for the following:
a Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
b Enter the number from the user and depending on whether the number is even or odd, print out an appropriate message to the user.
c Write a program to generate the Fibonacci series.
d Write a function that reverses the user defined value.
e Write a function to check the input value is Armstrong and also write the function for Palindrome.
f Write a recursive function to print the factorial for a given number.
2 Write the program for the following:
a Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise.
b Define a function that computes the length of a given list or string.
c Define a procedure histogram() that takes a list of integers and prints a histogram to the screen. For example, histogram([4, 9, 7]) should print the following:
****
*********
*******
3 Write the program for the following:
a A pangram is a sentence that contains all the letters of the English alphabet at least once, for example: The quick brown fox jumps over the lazy dog. Your task here is to write a function to check a sentence to see if it is a pangram or not.
b Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list that are less than 5.
4 Write the program for the following:
a Write a program that takes two lists and returns True if they have at least one common member.
b Write a Python program to print a specified list after removing the 0th, 2nd, 4th and 5th elements.
c Write a Python program to clone or copy a list
5 Write the program for the following:
a Write a Python script to sort (ascending and descending) a dictionary by value.
b Write a Python script to concatenate following dictionaries to create a new one.
Sample Dictionary:
dic1={1:10, 2:20}
dic2={3:30, 4:40}
dic3={5:50,6:60}
Expected Result: {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}
c Write a Python program to sum all the items in a dictionary.
6 Write the program for the following:
a Write a Python program to read an entire text file.
b Write a Python program to append text to a file and display the text.
c Write a Python program to read last n lines of a file.
7 Write the program for the following:
a Design a class that store the information of student and display the same
b Implement the concept of inheritance using python
c Create a class called Numbers, which has a single class attribute called MULTIPLIER, and a constructor which takes the parameters x and y (these should all be numbers).
i. Write a method called add which returns the sum of the attributes x and y.
ii. Write a class method called multiply, which takes a single number parameter a and returns the product of a and MULTIPLIER.
iii. Write a static method called subtract, which takes two number parameters, b and c, and returns b - c.
iv. Write a method called value which returns a tuple containing the values of x and y. Make this method into a property, and write a setter and a deleter for manipulating the values of x and y.
8 Write the program for the following:
a Open a new file in IDLE (“New Window” in the “File” menu) and save it as geometry.py in the directory where you keep the files you create for this course. Then copy the functions you wrote for calculating volumes and areas in the “Control Flow and Functions” exercise into this file and save it. Now open a new file and save it in the same directory. You should now be able to import your own module like this:
import geometry
Try and add print dir(geometry) to the file and run it.
Now write a function pointyShapeVolume(x, y, squareBase) that calculates the volume of a square pyramid if squareBase is True and of a right circular cone if squareBase is False. x is the length of an edge on a square if squareBase is True and the radius of a circle when squareBase is False. y is the height of the object. First use squareBase to distinguish the cases. Use the circleArea and squareArea from the geometry module to calculate the base areas.
b Write a program to implement exception handling.
9 Write the program for the following:
a Try to configure the widget with various options like: bg=”red”, family=”times”, size=18
b Try to change the widget type and configuration options to experiment with other widget types like Message, Button, Entry, Checkbutton, Radiobutton, Scale etc.
10 Design the database applications for the following:
a Design a simple database application that stores the records and retrieve the same
b Design a database application to search the specified record from the database.
c Design a database application to that allows the user to add, delete and modify the records.

Python Programming Reference Books

Title Think Python
Authors Allen Downey
Publisher O’Reilly
Edition 1st
Year 2012
Download Here
Title An Introduction to Computer Science using Python 3
Authors Jason Montojo, Jennifer Campbell, Paul Gries
Publisher SPD
Edition 1st
Year 2014
Download Here
Title Python GUI Programming Cookbook
Authors Burkhard A. Meier
Publisher Packt
Edition
Year 2015
Download Here
Title Introduction to Problem Solving with Python
Authors E. Balagurusamy
Publisher TMH
Edition 1st
Year 2016
Download Here
Title Murach’s Python programming
Authors Joel Murach, Michael Urban
Publisher SPD
Edition 1st
Year 2017
Download Here
Title Object-oriented Programming in Python
Authors Michael H. Goldwasser, David Letscher
Publisher Pearson Prentice Hall
Edition 1st
Year 2008
Download Here
Title Exploring Python
Authors Budd
Publisher TMH
Edition 1st
Year 2016
Download Here