Sei sulla pagina 1di 20

A

Industrial Training Report


On
Web Development Using Python
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE & ENGINEERING
(2019-2020)
By
Syed Tariq Mustafa
(1636310102)
Submitted to
Department of Computer Science & Engineering

AMBALIKA INSTITUTE OF MANAGEMENT &


TECHNOLOGY, LUCKNOW
Affiliated to
Dr. APJ ABDUL KALAM TECHNICAL UNIVERSITY,
LUCKNOW
DECLARATION
I hereby declare that I have completed my four weeks summer training at
INTERNSHALA, Lucknow from June 10, 2019 to July 10,
2019. I have declared that I have worked with full dedication during these four
weeks of training and my learning. Outcomes fulfil the requirements of training
for the award of the degree of
Bachelor of Technology, Ambalika Institute of Management and
Technology, Lucknow.

(Signature of Student)
Name of Student: Syed Tariq Mustafa
Registration No.
Date: 06/11/2019
ACKNOWLEDGEMENT
I wish to express my gratitude to, my tutor at internshala
for providing me with an opportunity to do my training and project
work in “fantasy cricket”. Under his guidance, I have completed my project
and tried my best to implement what I had learnt till now. I sincerely thank
Mr.Niranjan Srivastav Sir, our institute project co-coordinator for their
guidance and encouragement to do my training. He also helps me by updating
us about the information of what to do and not to do during our training and
helps us with all.
I also thank my friend for helping me with the problem that I face in my
project.
Tables of contents:

1. Introduction to Python:
What is Python?
Variables
Data Types
Conditional Execution
Boolean Expressions
Logical Operators
Chained Conditionals
Functions
5. Database Management

2. Iterators
Iterations
For Loop
While Loop

3. Data Structure
Strings
Lists
Tuples
Dictionaries
Tuples

4. OOPs in Python
Concept of Object-Oriented Programming
Introduction
In technical terms, Python is an object-oriented, high-level programming
language with integrated dynamic semantics primarily for web and app
development. It is extremely attractive in the field of Rapid Application
Development because it offers dynamic typing and dynamic binding options
Python is relatively simple, so it’s easy to learn since it requires a unique syntax
that focuses on readability. Developers can read and translate Python code
much easier than other languages. In turn, this reduces the cost of program
maintenance and development because it allows teams to work collaboratively
without significant language and experience barriers.

Additionally, Python supports the use of modules and packages, which means
that programs can be designed in a modular style and code can be reused
across a variety of projects. Once you’ve developed a module or package you
need, it can be scaled for use in other projects, and it’s easy to import or
export these modules.
One of the most promising benefits of Python is that both the standard library
and the interpreter are available free of charge, in both binary and source
form.

There is no exclusivity either, as Python and all th necessary tools are available
on all major platforms. Therefore, it is an enticing option for developers who
don’t want to worry about paying high development costs.

Python is a general-purpose programming language, which is another way to


say that it can be used for nearly everything. Most importantly, it is an
interpreted language, which means that the writter code is not actually
translated to a computer-readable format at runtime. Whereas, most
programming langauages do this conversion before the program is even run.
This type of language is also referred to as a “scripting language” because it
was initially meant to be used for trivial projects.

Variables
Python is dynamically type, which means that you don’t have to declare what
type each variable is. In python, variables are a strong placeholder for texts
and numbers. It must have a name so that you are able to find it again.
The variable is always assigned with the equal sign, followed by the value of
the variable.
Whitespaces and signs with special meanings in Python, as “+” and “-” are not
allowed.
Usually, use lowercase with words separated by underscores as necessary to
improve readability.
Remeber that variable names are case sensitve.
There are some reserverd words for Python and can not be used as a variable
name.
For e.g
X = 124 # Integer
Y = 12.5 # Float
Z = “abc” # String

Data Types
1. Integers:
There is effectively no limit to how long an integer value can be. Of course, it
is constrained by the amount of memory your system has, as are all things, but
beyond that, an integer can ve as long as you need it to be:
For e.g:
>>> a = 10233019801923893813
>>> print(a)
Output: 10233019801923893813
X = 124 # Integer
Y = 12.5 # Float
Z = “abc” # String

specified with a decimal point.


For e.g.
>>> a = 4.2323
>>> print(a)
Output: 4.2323
3. Complex Numbers
Complex numbers are specified as <real part> + <imaginary part>j.
For e.g.
>>> a = 2+3j
>>>print(a)
Output: (2+3j)

4. Strings
Strings are squence of character data. The string type in Python is called str.
String literals may be delimited using either single or double quotes. All the
characters between the opening delimiter and matching closing delimiter are
part of the string.
For e.g.
>>> a = “I am Champion.”
>>> print(a)
Output: I am Champion

5. Boolean Type, Boolean Context and “Truthiness”


Python 3 provides a boolean data type. Objects of boolean type may have one
of two values, True or False.
For e.g:
>>> a = True
>>> print(a)
Output : True

Conditional Execution
Boolean Expression:
A boolean expression is an expression that is either true or false. The
following examples use the operator “==”, which compares two operands and
produces True if they are equal and False otherwise.
For e.g:
>>> “abc” == “ABC”
False
>>> “a” in “ABCa”
True
>>> True == False
False
>>> (2 + 2) == (2 * 2)
True
Flow Chart of Boolean operator:

Logical Operators:
There are thre logical operators: AND, OR and NOT. The semantics of these
operators is similar to their meaning in English.
For e.g.
x > 0 and x < 10 is True only if x is greater than 0 and less than 10.
“Near” is not “L” is True as “Near” does not match to “L”

Data flow diagram:


Conditional Execution
In order to write useful programs, we almost always need the ability to check
conditions and change the behaviour of the program accordingly. Conditional
Statements gives us this ability. The simplest form is the if statement
For e.g:
if x > 0:
print(“%s is positive” % x)
else:
print(“%x is non positive” % x)
The boolean expression afther the if statement is called the condition. We end
the if statement with a colon character (:) and the line(s) after the if statement
are intended.

the logical condition is false, the indented statement is skipped.

Chained Conditionals:
Sometimes there are more than two possibilities and we need more than two
branches. One way to express a computation like that is a chained
conditional.
For e.g:
if x > 0:
print(“x is positive”)
elif x == 0:
print(“x is zero”)
else:
print(“x is negative”)
elif is an abbreviation of “else if”. Again, exactly one branch will be
executed.
There is no limit on the number of elif statements. If there is an else clause,
it has to be at the end, but there doesn’t have to be one.
Each condition is checked in order. If the first is false, the next is checked
and so on. If one of them is true, the corresponding branch executes, and the
statement ends. Even if more than one condition is true, only the first true
branch executes.
Functions

A function is a block of organized, reusable code that is used to perform a


single, related action. Functions provide better modularity for your application
and a high degree of code reusing.
As you already know, Python gives you many built-in funcitons like print(),
etc., but you can also create your own functions. These functions are called
user-defined functions.

Defining a functions:

You can define functions to provide the required functionality. Here are simple
rules to define a function in Python.
Function blocks begin with the keyword def followed by the function name
and parentheses ().
Any input parameters or arguments should be placed within these parenthesis.
You can also define parameters inside these parentheses.
The first statement of a function can be an optional statement – the
documentation string of the function or docstring.
The code block within every function starts with a colon (:) and is indented.
The statement return exits a function, optionally passing back an expression to
the caller. A return statement with no arguments is the same as return None.
For Example:
def addTwoNumber(a, b):
“““
A function to add two integer numbers
”””
c=a+b
return c

Iterations:

For Loop:
For loops are used for sequential traversal. For instance, traversing a list or
string or array etc. In Python, there is no C style for loop. There is “for in”
loop which is similar to for each loop in other languages. Let us learn how to
use for in loop for sequential traversals.
For e.g:
Program to store the square of each number temporary
# List of integers numbers
numbers = [1, 2, 3, 4, 5]
# variable to store the square of each number temporary
sq = 0
# Iterating through the given list
for val in numbers:
# Calculating square of each number
sq = val * val
# displaying the squares
print(sq)

Output:
1
4
36
121
400

While loop is used to execute a block of statements repeatedly until a given


condition is satisfied and when the condition becomes false, the line
immediately after the loop in program is executed.
Syntax:
while expression:
statement(s)
All the statements indented by the same number of character spaces after a
programming construct are considered to be part of a single block of code.
Python uses indentation as its method of grouping statements.

Flow Chart:

Data Structure in Python

Lists:
Lists are just like the arrays, declared in other languages. Lists need not be
homogeneous always which makes it a most powerful tool in Python. A single
list may contain DataTypes like integers, strings, as well as objects. Lists are
also very useful for implementing stacks and queues. Lists are mutable, and
hence, they can be altered even after their creation.
In Python, list is a type of container in Data Structures, which is used to store
multiple data at the same time. Unlike Sets, the list in Python are ordered and
have a definite count. The elements in a list are indexed according to a definite
place in the list, which allows duplicating of elements in the list, with each
elements having its own distinct place and credibility.
Lists in Python can be created by just placing the sequence inside the square
brackets[]. Unlike Sets, list doesn’t need a built-in function for creation of list.
A list may contain duplicate values with their distinct positions and hence,
multiple distinct or duplicate values can be passed as a sequence at the time of
list creation.
Note – Unlike Sets, list may contain mutable elements.

Example:
Creation a list
List = []
print(“Initial black List:”)
print(List)
# Creating a List with the use of string
List = [“I am Champion”]
print(“\n List with the use of string”)
print(List)

Output:
Initial blank List:
[]
List with the use of String:
[‘I am Champion’]

Tuples:
Tuple is a collection of Python objects much like a list. The sequence of values
stored in a tuple can be of any type, and they are indexd by integers. The
important difference between a list and a tuple is that tuples are immutable.
Also, Tuples are hashable whereas lists are not.
Values of a tuple are syntactically separated by “commas”. Although it is not
necessary, it is more common to define a tuple by closing the sequence of
values
in parentheses. This helps in understanding the Python tuples more easily.
Tuples are created by placing sequence of values separated by “comma” with
or
without the use of parentheses for grouping of data structure. Tuples can
contain
any number of elements and of any datatype (like strings, integers, list, etc.).
Tuples can also be created with a single element, but is is a bit tricky. Having
one element in the parentheses is not suffiecient, there must be a trailing
“comma” to make it a tuple.
Note – Creation of Python tuple without the use of parentheses is known as
Tuple Packing

Example:
# Creating an empty tuple
Tuple = ()
print(“Initial empty Tuple”)
print(Tuple)
# Creating a tuple with the use of string
Tuple = (‘CHAMPION’, ‘CHAMP’)
print(“Tuple with the use of string”)
print(Tuple)

Output:
Initial empty Tuple
()
Tuple with the use of string
(‘CHAMPION’, ‘CHAMP’)
Sets:
Set is an unordered collection of data type that is iterable, mutable and has no
duplicate elements.
Set in Python is equivalent to sets in mathematics. The order of elements in a
set is undefined though it may consist of various elements. Elements of a set
can be added and deleted, elements of the set can be iterated, various
standardoperations (union, intersection, difference) can be performed on sets.
Besides that, the major advantage of using a set, as opposed to a list, is that it
has a highly optimized method for checking whether a specific elements is
contained in the setSets can be created by using the built-in set() function with
an iterable object ora sequence by placing the sequence inside curly braces,
separated by “comma”.
A set contains only unique elements but at the time of set creation, multiple
duplicate values can also be passed. Order of elements in a set is undefined
and is unchangeable. Type of elements in a set need not be the same, various
mixed up data type values can also be passed to the set.
Example:
# Creating a Set
Set = set()
print(“Initial blank set”)
print(Set)
# Creating a set with the use of a string
Set = set(‘Champ’)
print(“Set with the use of string”)
print(Set)
# Creating a set with the use of curly braces
Set = {‘Champ’, ‘is’, ‘human’}
print(“Set with curly braces”)
print(Set)

Output:
Initial blank set
set()
Set with the use of string
{‘C’, ‘h’, ‘a’, ‘m’, ‘p’}
Set with curly braces
{‘is’, ‘human’, ‘Champ’}
Concept of Object-Oriented Programing:
Python is also an object-oriented language since its beginning. Python is an
object-oriented programming language. It allows us to develop applications
using an Object Oriented approach. In Python, we can easily create and use
classes and objects.
Major principles of object-oriented programming system are given below.
Object
Class
Method
Inheritance
Polymorphism
Data Abstraction
Encapsulation

Object:
The object is an entity that has state and behavior. It may be any real-world
object like the mouse, keyboard, chair, table, pen, etc.
Class:
The class can be defined as a collection of objects. It is a logical entity that has
some specific attributes and methods. For example: if you have an employee
class then it should contain an attribute and method, i.e. an email id, name,
age,
salary, etc.
Syntax
class ClassName:
<statement-1>
.
.
<statement-N>
Method:
The method is a function that is associated with an object. In Python, a method
is
not unique to class instances. Any object type can have methods.

Inheritance:
Inheritance is the most important aspect of object-oriented programming
which
simulates the real world concept of inheritance. It specifies that the child
object
acquires all the properties and behaviors of the parent object.
By using inheritance, we can create a class which uses all the properties and
behavior of another class. The new class is known as a derived class or child
class, and the one whose properties are acquired is known as a base class or
parent class.
It provides re-usability of the code.
Python unlike C++ and Java support multiple inheritance.
Polymorphism:
Polymorphism contains two words "poly" and "morphs". Poly means many and
Morphs means form, shape. By polymorphism, we understand that one task
can
be performed in different ways. For example You have a class animal, and all
animals speak. But they speak differently. Here, the "speak" behavior is
polymorphic in the sense and depends on the animal.
So, the abstract "animal" concept does not actually "speak", but specific
animals
(like dogs and cats) have a concrete implementation of the action "speak".

Encapsulation:
Encapsulation is also an important aspect of object-oriented programming. It is
used to restrict access to methods and variables. In encapsulation, code and
data
are wrapped together within a single unit from being modified by accident.

Data Abstraction:
Data abstraction and encapsulation both are often used as synonyms. Both are
nearly synonym because data abstraction is achieved through encapsulation.
Abstraction is used to hide internal details and show only functionalities.
Abstracting something means to give names to things so that the name
captures
the core of what a function or a whole program does.
Data Abstraction is a key feature for any programming language to support

Potrebbero piacerti anche