Unit 1
Unit 1
Programming
Basic Python to All
CO3 Determine the methods to create and manipulate Python programs by utilizing
the data structures like lists, dictionaries, tuples and sets.
CO4 Identify the commonly used operations involving file systems and regular
expressions.
CO5 Articulate the Object-Oriented Programming concepts such as encapsulation,
inheritance and polymorphism as used in Python
2 Python Program Flow Control Conditional blocks: if, else and else if, Simple for loops
in python, For loop using ranges, string, list and dictionaries. Use of while loops in python,
Loop manipulation using pass, continue, break and else. Programming using Python
conditional and loop blocks.
3 Python Complex data types: Using string data type and string operations, Defining list
and list slicing, Use of Tuple data type. String, List and Dictionary, Manipulations Building
blocks of python programs, string manipulation methods, List manipulation. Dictionary
manipulation, Programming using string, list and dictionary in-built functions. Python
Functions, Organizing python codes using functions.
UNIT TOPICS
4 Python File Operations: Reading files, Writing files in python, Understanding read
functions, read(), readline(), readlines(). Understanding write functions, write() and
writelines() Manipulating file pointer using seek Programming, using file operations.
5 Python packages: Simple programs using the built-in functions of packages matplotlib,
numpy, pandas etc. GUI Programming: Tkinter introduction, Tkinter and
PythonProgramming, Tk Widgets, Tkinter examples. Python programming with IDE.
Its user-friendliness does not take away from its strength. Python can
execute a variety of complex computations and is one of the most
powerful programming languages preferred by specialists.
▪ From the Upload button in the top-right corner, you can upload a notebook into the directory you are in. You can
expand the New button. From the list that falls, you will most likely need to create a new text file, a new folder, or a
new notebook file
BASIC SYNTAX
Correct Erroneous
if True: if True:
print "True" else: print "Answer" print
print "False" "True"
else:
print "Answer" print
"False"
One of the main concepts in programming is variables. They are your best friends. You will deal
with them all the time. You will use them to store information. They will represent your data input.
counter = 100
Numbers
miles = 1000.0
+, -, *, /, %, ** (exponent), // (floor
Arithmetic Operators
division)
❖ Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes
starting at 0 in the beginning of the string and working their way from -1 to the end
❖ Lists are the most versatile of Python's compound data types. A list contains items
separated by commas and enclosed within square brackets ([]).
❖ To some extent, lists are similar to arrays in C. One of the differences between
them is that all the items belonging to a list can be of different data type.
❖ The values stored in a list can be accessed using the slice operator ([ ] and [:]) with
indexes starting at 0 in the beginning of the list and working their way to end - 1.
❖ The plus(+) sign is the list concatenation operator, and the asterisk (*) is the
repetition operator.
❖ The main difference between lists and tuples is- Lists are enclosed
in brackets ( [ ] ) and their elements and size can be changed, while
tuples are enclosed in parentheses ( ( ) )and cannot be updated.
Tuples can be thought of as read-only lists.
Python's dictionaries are kind of hash-table type. They work like associative
arrays or hashes found in Perl and consist of key-value pairs.
A dictionary key can be almost any Python type, but are usually numbers or
strings. Values, on the other hand, can be any arbitrary Python object.