PHONE +91 9620196773, +91 8884684156
EMAIL info@iqstreamtech.com
Call for Free Demo +91 9620196773, +91 8884684156, 080-42073645


Syllabus

Useful Info on Python

Useful Concepts and Programs

Best Python Training in Bangalore

Introduction

History
Features
Setting up path
Working with Python
Basic Syntax
Variable and Data Types
Operator

Conditional Statements

If
If- else
Nested if-else

Looping

For
While
Nested loops

Control Statements

Break
Continue
Pass

String Manipulation

Accessing Strings
Basic Operations
String slices
Function and Methods

Lists

Introduction
Accessing list
Operations
Working with lists
Function and Methods

Tuple

Introduction
Accessing tuples
Operations
Working
Functions and Methods

Dictionaries

Introduction
Accessing values in dictionaries
Working with dictionaries
Properties
Functions

Functions

Defining a function
Calling a function
Types of functions
Function Arguments
Anonymous functions
Global and local variables

Modules

Importing module
Math module
Random module
Packages
Composition

Input-Output

Printing on screen
Reading data from keyboard
Opening and closing file
Reading and writing files
Functions

Exception Handling

Exception
Exception Handling
Except clause
Try ? finally clause
User Defined Exceptions

Advanced Python

OOPS

Attributes Inheritance Overloading Overriding Data hiding

Regular expressions

Match function
Search function
Matching VS Searching
Modifiers
Patterns

CGI

Introduction
Architecture
CGI environment variable
GET and POST methods
Cookies
File upload

Database

Introduction
Connections
Executing queries
Transactions
Handling error

Networking

Socket
Socket Module
Methods
Client and server
Internet modules

Multithreading

Thread
Starting a thread
Threading module
Synchronizing threads
Multithreaded Priority Queue

GUI Programming

Introduction
Tkinter programming
Tkinter widgets

Some useful info on Python

Difference between Python2 and Python3:

Python3 was released in year 2008. Python3 stopped supporting some of the syntax of its predecssor Python2.7. Python2.7 is supposed to be retired and it's no longer be used.
There are several differences between Python2.7 and Python3.0. Here are a few major differences:
1. Python3.0 has different division from Python2.7: In Python2, 5/2 will result 2, where as 5.0/2.0 results 2.5
That means, if you are not using decimals in any of the two numbers, the result will not truncate the value after decimal point.
In Python3.0, 5/2 will result 2.5, which is as expected.
This way, Python3 is more intuitive. That's one reason why it has become more popular over Python2

2. Difference in 'print' statement: Python2, it was a print statement whereas it's replaced by print() function in Python3.
Python2: print "hello"
Python3: print("hello")

3. Strings ASCII vs UNICODE: In Python2, Strings are stored as ASCII, you have to add a “u” if you want to store strings as Unicode in Python 2.x.
In Python3, String are stored as Unicode by default

This is important because Unicode is more versatile than ASCII. Unicode strings can store foreign language letters, Roman letters and numerals, symbols, emojis, etc., offering you more choices.

How to convert Python2.x code to Python3.x

2to3 is a Python program, that can read the 2.x source and convert to 3.x code. The is program is located under Tools/scripts folder.

Some Useful Concepts and Programs in Python

Print even numbers within a given number (include the given number)

Program:
limit = 20;
print ("Even Numbers within: ", limit);
for n in list(range(1, limit+1)):
   if (n%2==0):
     print(n, end =" ")
print() print ("End of the program")
Output:
Even Numbers within: 20
2 4 6 8 10 12 14 16 18 20
End of the program

List in Python: some common usage

Program:
l = [0,1,2,3,4,5,6,7,8,9]
print ("Length of the list: ", len(l))
l1 = l[:3]
print ("Sub list below index 3: ", l1)
l2 = l[3:]
print ("Sub list from index 3 (includes): ", l2)
l3 = l[:-2]
print ("List excluding last 2 elements from the list: ", l3)

l3a = l[-2:]
print ("Last 2 elements from the list: ", l3a)

l4=[10, 11]
l.extend(l4);
print ("Concatenate two lists: ", l)

l.append(12);
print ("Append one element to the list: ", l)

l6 = [89,45,9,23,89,5,890,3,60,45,9]
print("Original list, before sort: ",l6);
l6.sort();
print("Sorted list ascending: ",l6);
l6.sort(reverse=True)
print("Sorted list descending: ",l6)

# list of lists
list1 = ['first', 'second']
list2 = ['third', 'fourth']
list1Andlist2 = [list1, list2]
print ('list1: ', list1)
print ('list2: ', list2)
print ('lis of lists: ', list1Andlist2)

# Access a specific element in the list
print ('index 1 is second element: ', list1[1])
print ('index 0 is first element: ', list1[0])

Output:
Length of the list: 10
Sub list below index 3: [0, 1, 2]
Sub list from index 3 (includes): [3, 4, 5, 6, 7, 8, 9]
List excluding last 2 elements from the list: [0, 1, 2, 3, 4, 5, 6, 7]
Last 2 elements from the list: [8, 9]
Concatenate two lists: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Append one element to the list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
Original list, before sort: [89, 45, 9, 23, 89, 5, 890, 3, 60, 45, 9]
Sorted list ascending: [3, 5, 9, 9, 23, 45, 45, 60, 89, 89, 890]
Sorted list descending: [890, 89, 89, 60, 45, 45, 23, 9, 9, 5, 3]
list1: ['first', 'second']
list2: ['third', 'fourth']
lis of lists: [['first', 'second'], ['third', 'fourth']]
index 1 is second element: second
index 0 is first element: first

Tuple in Python: some examples

Program:
# Tuple. They are similar to Lists and immutable. Just use () instead of []. Use tuple when you have fixed lists
weekdays = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')
print ('Week days: ', weekdays);
print ("Week's first day: ", weekdays[0])
print ("Week's last day: ", weekdays[len(weekdays)-1])

Output:
Week days: ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')
Week's first day: Monday
Week's last day: Sunday

Dictionary in Python: some examples

Program:
#Dictionary is similar to Map in Java
examSchedule = {}
examSchedule['Mon'] = 'English'
examSchedule['Tue'] = 'Maths'
examSchedule['Wed'] = 'Science'
examSchedule['Thu'] = 'Social'
examSchedule['Fri'] = 'French'

print ("Monday:", examSchedule['Mon'])
print ("Monday:", examSchedule.get('Mon'))
print()

#Loop through a dictionary
for key in examSchedule:
print(key, ':', examSchedule[key])

print();
#Check if a key exists
if "Tue" in examSchedule:
print("'Tue' exists in examSchedule and the value is: ", examSchedule['Tue'])
else:
print("'Tue' not exists in the examSchedule")

print()
#Remove an item in Dictionary
examSchedule.pop("Tue");
print("'Tue' is popped");
if "Tue" in examSchedule:
print("'Tue' exists in examSchedule and the value is: ", examSchedule['Tue'])
else:
print("'Tue' not exists in the examSchedule")

print()
# Clear emptys the dictionary
examSchedule.clear()
print("Dictionary after clear: ", examSchedule)

Output:
Monday: English
Monday: English

Fri : French
Mon : English
Wed : Science
Tue : Maths
Thu : Social

'Tue' exists in examSchedule and the value is: Maths

'Tue' is popped
'Tue' not exists in the examSchedule

Dictionary after clear: {}

Functions in Python: Example1

Program:
def add(a, b):
    return a + b

x=10
y=20
print ("Sum of", x, "and", y, "is:", add(x, y))

# Using function as Param
def callAdd(addFunc, x, y):
    return addFunc(x,y)

s = callAdd(add, 20, 30)
print ("Sum of 20 and 30 is:", s)

Output:
Sum of 10 and 20 is: 30
Sum of 20 and 30 is: 50

Function as Param in Python: Example2

Program:
# return Junior or Senior based on the experience only two conditions
def empType(experience):
    if (experience < 8):
        return 'Junior'
    else:
        return 'Senior'

# return Junior or Senior or Executive based on the experience three conditions
def empType1(experience):
    if (experience < 8):
        return 'Junior'
    elif (experience < 15):
        return 'Senior'
    else:
        return 'Executive'

#Using function as parameter for another function
# Bonus based on the emp type
def empBonus(empTypeFunc, exp):
    eType = empTypeFunc(exp)
    if (eType == 'Junior'):
        return 20
    elif (eType == 'Senior') :
        return 10
    else:
        return 5

#Calling empType, will treat 16 years as Senior and hence Bonus as 10
print ("Case1, Bonus for 16 years of Emp: ", empBonus(empType, 16))
#Calling empType, will treat 16 years as Executive and hence Bonus as 5
print ("Case2, Bonus for 16 years of Emp: ", empBonus(empType1, 16))

Output:
Case1, Bonus for 16 years of Emp: 10
Case2, Bonus for 16 years of Emp: 5

Numpy and Pandas Library in Python

Numpy means Numerical Python. This library consists of multi-dimensional array objects and collections of routines to handle them.This is specifically useful for developing algorithms. It is also widely used in the areas of shape manipultation and linear algebra.

Pandas library provides tools for data structures and data analysis. This library widely used in the field of data science and mahine learning.

Program1: One dimensional and two dimensional data using Numpy
import numpy as np

marks = np.array([80, 90, 95, 75])
sub = np.array(['English', 'Maths', 'Science', 'French'])
sub_and_marks = np.array([sub, marks])

print("Marks array:", marks)
print("Subjects array:",sub)
print("Subjects and Marks:",sub_and_marks)

Output:
Marks array: [80 90 95 75]
Subjects array: ['English' 'Maths' 'Science' 'French']
Subjects and Marks: [['English' 'Maths' 'Science' 'French']
['80' '90' '95' '75']]

enquiry