PDF Python Programming Compress
PDF Python Programming Compress
PYTHON PROGRAMMING
OBJECTIVES:
Introduction to Scripting Language
Exposure to various problems solving approaches of computer science
UNIT – I:
I:
Introduction: History of Python, Need of Python Programming, Applications Basics of
Python Programming Using the REPL(Shell), Running Python Scripts, Variables,
Assignment,
Assignmen t, Keyw
Keywords,
ords, Inpu
Input-Output,
t-Output, Indenta
Indentation.
tion.
UNIT – II:
II:
Types, Operators and Expressions: Types - Integers, Strings, Booleans; Operators-
Arithmetic Operators,
Operators, Compariso
Comparisonn (Relatio
(Relational)
nal) Oper
Operators,
ators, Assignment
Assignment Operators,
Operators,
Logical Operators, Bitwise Operators, Membership Operators, Identity Operators,
Expressions and order of evaluations Control Flow- if, if-elif-else, for, while, break,
continue, pass.
UNIT – III:
III:
Data Structures Lists - Operations, Slicing, Methods; Tuples, Sets, Dictionaries,
Sequences. Comprehensions.
UNIT – IV:
IV:
Functions - Defining Functions, Calling Functions, Passing Arguments, Keyword
Arguments, Default Arguments,
Arguments, Arguments, Variable-
Variable-length
length arg
arguments,
uments, Anonymous
Anonymous Functions,
Functions,
Fruitful Functions(Function Returning Values), Scope of the Variables in a Function -
Global and Local Variables.
Modules: Creating modules, import statement, from. Import statement, name spacing,
Python packages, Introduction to PIP, Installing Packages via PIP, Using Python
Packages
UNIT – V:
V:
Object Oriented Programming OOP in Python: Classes, 'self variable', Methods,
Constructor Method, Inheritance, Overriding Methods, Datahiding,
Error and Exceptions: Difference between an error and Exception, Handling Exception,
try except block, Raising Exceptions, User Defined Exceptions
UNIT – VI:
VI:
Brief Tour of the Standard Library - Operating System Interface - String Pattern
Matching, Mathematics, Internet Access, Dates and Times, Data Compression,
Multithreading, GUI Programming, Turtle Graphics
Testing: Why testing is required ?, Basic concepts of testing, Unit testing in Python,
Writing Test cases, Running Tests.
OUTCOMES:
TEXT BOOKS
Reference Books:
Exercise 1 - Basics
a) Running instructions in Interactive interpreter and a Python Script
b) Write a program to purposefully raise Indentation Error and Correct it
Exercise 2 - Operations
a) Write a program to compute distance between two points taking input from the user
(Pythagorean Theorem)
b) Write a program add.py that takes 2 numbers as command line arguments and prints
its sum.
Exercise - 5 - DS
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.
Exercise - 6 DS - Continued
a) Write a program combine_lists that combines these lists into a dictionary.
b) 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?
Exercise - 7 Files
a) Write a program to print each line of a file in reverse order.
order.
b) Write a program to compute the number of characters, words and lines in a file.
Exercise - 8 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.
Exercise - 12 - Modules
a) Install packages requests, flask and explore them. using (pip)
b) Write a script that imports requests and fetch content from the page. Eg. (Wiki)
c) Write a simple script that serves a simple HTTPResponse and a simple HTML Page
Exercise - 13 OOP
a) Class variables and instance variable and illustration of the self variable
i) Robot
ii) ATM Machine
Exercise - 15 - Testing
a) Write a test-case to check the function even numbers which return True on passing a
list of all even numbers.
b) Write a test-case to check the function reverse_string which returns the reversed
string.
Exercise - 16 - Advanced
a) Build any one classical data structure
b) Write a program to solve knapsack problem