Python and Django
Forfatter
Prachi Khandelwal
Sidst opdateret
5 år siden
Licens
Creative Commons CC BY 4.0
Resumé
This report is about Python and Django and can be useful for students for report submission.
This report is about Python and Django and can be useful for students for report submission.
\documentclass[a4paper,12pt,]{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{microtype}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{index}
\usepackage[utf8]{inputenc}
%FRONT PAGE
\begin{document}
\pagenumbering{roman}
\clearpage\thispagestyle{empty}
\centering
\textbf{\LARGE "Python Technology"}\\
\emph{\Large
A\\
{Industrial Training Project}\\
Submitted\\
in partial fulfillment\\
for the award of the Degree of\\
{Bachelor of Technology}\\
{in Department of Computer Science \& Engineering}\\}
\textbf {\small{(With specialization in Computer Science \& Engineering)}}\\
\includegraphics[width=10cm]{image1.jpg/mitrc.png}\\
\large{
\textbf{Submitted to:} \hfill \textbf{Submitted By:}\\
Mr. Shashi Kant\hfill Prachi Khandelwal\\
Assistant Prof.(CSE) \hfill 17EMCCS076\\[.5in]
}
\centering
{\emph{\Large Department of Computer Science \& Engineering}}\\
\emph{\Large Modern Institute of Technology \& Research Centre}\\
\emph{\Large Rajasthan Technical University , Kota}\\
\textbf{\Large October,2019}\\
\newpage
\addcontentsline{toc}{chapter}{\numberline{}Certificate}%
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{image1.jpg/certificate_rotate.png}
\newpage
% ACKNOWLEDGEMENT
\chapter*{\centering Acknowledgement}%
\addcontentsline{toc}{chapter}{\numberline{}Acknowledgement}%
\begin{flushleft}
I would like to express my deepest appreciation to all those who provided me the possibility to complete this report. A special gratitude I give to our Prof. S.K Sharma of MITRC, Alwar . Whose contribution in stimulating suggestions and encouragement, helped me to coordinate my project especially in writing this report.\newline
Furthermore I would also like to acknowledge with much appreciation the crucial role of Mr. Manish Kumar Mukhijia, for creating constant push to move forward who gave the permission to use all required equipment and the necessary materials to complete the task and I am also grateful to our HOD-CSE Mr. Arvind Sharma for the prompt and very valuable support to necessary infrastructure required for the project work. \newline
Last but not least, many thanks go to the head of the project,Mr. Shashikant who have invested his full effort in guiding the team in achieving the goal. I have to appreciate the guidance given by other supervisor as well as the panels especially in our project presentation that has improved our presentation skills thanks to their comment and advice.\newline
Thank you \\
Prachi Khandelwal
\end{flushleft}
%ABSTRACT
\newpage
\chapter*{\centering Abstract}%
\addcontentsline{toc}{chapter}{\numberline{}Abstract}%
\section*{\centering Python Technology}
\begin{flushleft}
With the advent of Information Technology in the last decade, the major focus has shifted from manual systems to computerised systems. Now this time is the era of connecting people's from one place to another ,so that they can share their ideas , interest of knowledge and can help in grooming of other person . My " Tech Blog Website" is an online platform to do such things here people can share their ideas regarding the technical trends and science emergencing world .I have developed this website using Python , Django and Javascript as backend and Sql for data structure. HTML, CSS and Bootstrap for Frontend.
\end{flushleft}
\tableofcontents
\listoffigures
\listoftables
\begin{flushleft}
\chapter{Python Introduction}
\section{\textbf{What is Python ?}}
\pagenumbering{arabic}
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
\newline
It is used for
\begin{itemize}
\item web development (server-side)
\item software development
\item mathematics
\item system scripting
\end{itemize}
\section{\textbf What can Python do?}
\begin{itemize}
\item Python can be used on a server to create web applications.
\item Python can be used alongside software to create workflows.
\item Python can connect to database systems. It can also read and modify files.
\item Python can be used to handle big data and perform complex mathematics.
\item Python can be used for rapid prototyping, or for production-ready software development.
\end{itemize}
\section{Why Python?}
\begin{itemize}
\item Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
\item Python has a simple syntax similar to the English language.
\item Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
\item Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
\item Python can be treated in a procedural way, an object-orientated way or a functional way.
\end{itemize}
\section{Python Enviroment Setup}
We have set up the Python Programming environment online, so that you can compile and execute all the available examples online. It will give you the confidence in what you are reading and will enable you to verify the programs with different options. Feel free to modify any example and execute it online. \newline
Try the following example using our online compiler available at Coding Ground \newline\newline
\boxed{/user/bin/python3/print ("Hello, Python!")}
\newline
For most of the examples given in this tutorial, you will find a Try it option on our website code sections, at the top right corner that will take you to the online compiler. Just use it and enjoy your learning. \newline
Python 3 is available for Windows, Mac OS and most of the flavors of Linux operating system. Even though Python 2 is available for many other OSs, Python 3 support either has not been made available for them or has been dropped
\newpage
\chapter{Python Syntax}
\section{Python Indentation}
Indentation refers to the spaces at the beginning of a code line.\newline
Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.\newline
Python uses indentation to indicate a block of code.\newline\newline
\large{Example}\\
\boxed{if \hspace{9pt}5 > 2:\newline
print("Five \hspace{2pt} is \hspace{2pt} greater \hspace{2pt} than \hspace{2pt} two ! ")}
\section{Python Variables}
In Python variables are created the moment you assign a value to it: \newline
Python has no command for declaring a variable.\\
\section{Comments}
Python has commenting capability for the purpose of in-code documentation.\newline
\textbf{Comments start with a \#
\, and Python will render the rest of the line as a comment:}
\section{Reserved Keyword}
\begin{center}
\begin{table}[h!]
\centering
\begin{tabular}{c|c|c}
\hline
and & assert & in \\
del & else & raise \\
from & if & continue \\
not & pass & finally \\
while & yield & is \\
as & break & return \\
elif & except & def \\
global & import & for \\
or & print & lambda \\
with & class & try \\
exec & & \\
\hline
\end{tabular}
\caption{Reserved Keyword}
\label{tab:Reserved Keywordl}
\end{table}
\end{center}
%BUILTIN DATATYPE
\newpage
\chapter{Python Data Types}
\section{Built-in Data Types}
In programming, data type is an important concept.\par
Variables can store data of different types, and different types can do different things.\par
Python has the following data types built-in by default, in these categories:\par
\begin{figure}
\centering
\includegraphics[width=8cm]{image1.jpg/latex_datatype.png}
\caption{Builtin Datatype}
\label{fig:Builtin-Datatype}
\end{figure}
\newpage
\chapter{Python Numbers}
\section{Numbers}
There are three numeric types in Python:
\begin{itemize}
\item int
\item float
\item complex
\end{itemize}
Variables of numeric types are created when you assign a value to them:\\
\includegraphics[width=10cm]{image1.jpg/number_1_latex.png}
\par
To verify the type of any object in Python, use the type() function:\\
\includegraphics[width=10cm]{image1.jpg/number_2.png}\\
\subsection{Int}
Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length.\\
\includegraphics[width=10cm]{image1.jpg/int.png}\\
\subsection{Float}
Float, or "floating point number" is a number, positive or negative, containing one or more decimals.\\
\includegraphics[width=10cm]{image1.jpg/float.png}\\
\subsection{Complex}
Complex numbers are written with a "j" as the imaginary part:
\includegraphics[width=10cm]{image1.jpg/complex.png}\\
\section{Type Conversion}
You can convert from one type to another with the int(), float(), and complex() methods:\\
\includegraphics[width=10cm]{image1.jpg/conversion.png}\\
\section{Random Number}
Python does not have a random() function to make a random number, but Python has a built-in module called random that can be used to make random numbers:
\includegraphics[width=10cm]{image1.jpg/random.png}\\
\newpage
\chapter{Python Casting}
\section{Specify a Variable Type}
There may be times when you want to specify a type on to a variable. This can be done with casting. Python is an object-orientated language, and as such it uses classes to define data types, including its primitive types.\par
Casting in python is therefore done using constructor functions:\newline
\begin{itemize}
\item int() -\descriptionlabel{ constructs an integer number from an integer literal, a float literal (by rounding down to the previous whole number), or a string literal (providing the string represents a whole number)}
\item float() - \descriptionlabel{constructs a float number from an integer literal, a float literal or a string literal (providing the string represents a float or an integer)}
\item str() - \descriptionlabel{constructs a string from a wide variety of data types, including strings, integer literals and float literals}
\end{itemize}
\newpage\chapter{Python Strings}
\section{String Literals}
String literals in python are surrounded by either single quotation marks, or double quotation marks.\par
'hello' is the same as "hello".\par
You can display a string literal with the print() function:\\
\includegraphics[width=10cm]{image1.jpg/string.png}\\
\section{Strings are Arrays}
Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.\par
However, Python does not have a character data type, a single character is simply a string with a length of 1.\par
Square brackets can be used to access elements of the string.\\
\includegraphics[width=10cm]{image1.jpg/string_as_arrya.png}\\
\section{Slicing}
You can return a range of characters by using the slice syntax.\par
Specify the start index and the end index, separated by a colon, to return a part of the string.\par
\includegraphics[width=10cm]{image1.jpg/slicing.png}
\section{Negative Indexing}
Use negative indexes to start the slice from the end of the string:\\
\includegraphics[width=10cm]{image1.jpg/negetive_indexing.png}\\
\section{String Length}
To get the length of a string, use the len() function.\\
\includegraphics[width=10cm]{image1.jpg/length.png}\\
\section{String Methods}
Python has a set of built-in methods that you can use on strings.\\
\subsection{Strip}
\includegraphics[width=10cm]{image1.jpg/strip.png}\\
\subsection{Lower}
\includegraphics[width=10cm]{image1.jpg/lower.png}\\
\subsection{Upper}
\includegraphics[width=10cm]{image1.jpg/upper.png}\\
\subsection{ Concatenation}
\includegraphics[width=10cm]{image1.jpg/concatenate.png}\\
\newpage
\section{Methods}
\begin{figure}[!h]
\centering
\includegraphics[width=10cm]{image1.jpg/methods_string.png}
\caption{Built-in methods}
\label{fig:Built-in methods}
\end{figure}
\chapter{Python Operators}
Operators are used to perform operations on variables and values.\par
Python divides the operators in the following groups:\\
\begin{itemize}
\item Arithmetic operators
\item Assignment operators
\item Comparison operators
\item Logical operators
\item Identity operators
\item Membership operators
\item Bitwise operators
\end{itemize}
\section{Arithmetic Opertaors}
Arithmetic operators are used with numeric values to perform common mathematical operations:\newline
\begin{table}[h!]
\centering
\begin{tabular}{|c|c|c|c}
\hline
Operator & Name & Example \\
\hline
+ & Addition & x+y\\
- & Subtraction & x-y\\
* & Multiplication & x*y\\
/ & Division & x/y \\
** & Exponentiation & x**y\\
\hline
\end{tabular}
\caption{Arithmetic Operators}
\label{tab:Arithmetic Operators}
\end{table}
\section{ Assignment Operators}
Assignment operators are used to assign values to variables:
\begin{table}[h!]
\centering
\begin{tabular}{|c|c|}
\hline
Operator & Example \\
\hline
= & x=5\\
+= & x+=3\\
-= & x-=3\\
*= & x*=3\\
/= & x/=5\\
\hline
\end{tabular}
\caption{Assignment Operator}
\label{tab:Assignment Operator}
\end{table}
\section{Comparison Operators}
Comparison operators are used to compare two values:\\
\begin{table}[h!]
\centering
\begin{tabular}{|c|c|c|}
\hline
Operator & Name & Example \\
\hline
== & Equal & x==y\\
!= & Not equal & x!=y \\
> & Greater than & x>y\\
< & less than & x<y \\
>= & Greater than or equal to & x>=y \\
<= & Less than or equal to & x<=y \\
\hline
\end{tabular}
\caption{Comparison Operators}
\label{tab:Comparison Operators}
\end{table}
\section{Logical Operators}
Logical operators are used to combine conditional statements:\\
\begin{table}[ht]
\centering
\begin{tabular}{|c|c|c|}
\hline
Operator & Description & Example \\
\hline
and & Returns True if both statements are true & x < 5 and x < 10 \\
or & Returns True if one of the statements is true & x < 5 or x < 4 \\
not & Reverse the result, returns False if the result is true & (x < 5 and x < 10)\\
\hline
\end{tabular}
\caption{Logical Operators}
\label{tab:Logical Operators}
\end{table}
\section{Bitwise Operators}
Bitwise operators are used to compare (binary) numbers:\\
\begin{table}[ht!]
\centering
\begin{tabular}{|c|c|c|}
\hline
Opertaor & Name & Description \\
\hline
\& & AND & Sets each bit to 1 if both bits are 1\\
| & OR & Sets each bit to 1 if one of two bits is 1\\
<< & Zero fill left shift & Shift left by pushing zeros \\
>> & Signed right shift & Shift right by pushing bits fall off\\
\hline
\end{tabular}
\caption{Bitwise Operators}
\label{tab:Bitwise Operators}
\end{table}
\newpage
\chapter{Python Lists}
\section{Python Collections (Arrays)}
There are four collection data types in the Python programming language:\\
\begin{itemize}
\item List: \descriptionlabel{It is a collection which is ordered and changeable. Allows duplicate members.}
\item Tuple: \descriptionlabel{ It is a collection which is ordered and unchangeable. Allows duplicate members.}
\item Set: \descriptionlabel{ It is a collection which is unordered and unindexed. No duplicate members.}
\item Dictionary: \descriptionlabel{It is a collection which is unordered, changeable and indexed. No duplicate members.}
\end{itemize}
When choosing a collection type, it is useful to understand the properties of that type. Choosing the right type for a particular data set could mean retention of meaning, and, it could mean an increase in efficiency or security.\par
\section{List}
A list is a collection which is ordered and changeable. In Python lists are written with square brackets.\par
\includegraphics[width=10cm]{image1.jpg/list.png}\\
\subsection{Negative Indexing}
Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second last item etc.
\includegraphics[width=10cm]{image1.jpg/negetive_list.png}\\
\subsection{Loop Through a List}
You can loop through the list items by using a for loop:\\
\includegraphics[width=10cm]{image1.jpg/loop_list.png}\\
\subsection{List Length}
To determine how many items a list has, use the len() method:\\
\includegraphics[width=10cm]{image1.jpg/list_length.png}\\
\section{List Methods}
\begin{table}[h!]
\centering
\includegraphics[width=15cm]{image1.jpg/list_method.png}
\caption{List Method}
\label{tab:List Method}
\end{table}
\newpage
\chapter{Python Tuples}
\section{Tuple}
A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets.\\
\includegraphics[width=10cm]{image1.jpg/special_tuple.png}\\
\subsection{Access tuple Items}
You can access tuple items by referring to the index number, inside square brackets:\\
\includegraphics[width=10cm]{image1.jpg/Acces_tuple.png}\\
\subsection{Negetive Indexing}
Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second last item etc.\\
\includegraphics[width=10cm]{image1.jpg/negetive_tuple.png}\\
\subsection{Range Of Indexes}
You can specify a range of indexes by specifying where to start and where to end the range.\par
When specifying a range, the return value will be a new tuple with the specified items.\par
\includegraphics[width=10cm]{image1.jpg/range_tuple.png}\\
\newpage
\chapter{Python Sets}
\section{Set}
A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets.\\
\includegraphics[width=10cm]{image1.jpg/set.png}\\
\subsection{Access Items}
You cannot access items in a set by referring to an index, since sets are unordered the items has no index.\par
But you can loop through the set items using a for loop, or ask if a specified value is present in a set, by using the in keyword.\par
\includegraphics[width=10cm]{image1.jpg/Acces_set.png}\\
\subsection{Add Items}
To add one item to a set use the add() method.\\
To add more than one item to a set use the update() method.\\
\includegraphics[width=10cm]{image1.jpg/add_item_set.png}
\section{Set Methods}
Python has a set of built-in methods that you can use on sets.\\
\begin{table}[h!]
\centering
\includegraphics[width=10cm]{image1.jpg/set_methods.png}
\caption{Set Methods}
\label{tab:Set Methods}
\end{table}
\newpage
\chapter{Python Dictionaries}
\section{Dictionary}
A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values.\par
\includegraphics[width=10cm]{image1.jpg/dict.png}\\
\subsection{Accessing Items}
You can access the items of a dictionary by referring to its key name, inside square brackets:\\
\includegraphics[width=10cm]{image1.jpg/access_dict.png}\\
\subsection{Loop Through a Dictionary}
You can loop through a dictionary by using a for loop.\par
When looping through a dictionary, the return value are the keys of the dictionary, but there are methods to return the values as well.\par
\includegraphics[width=10cm]{image1.jpg/loop_dict.png}\\
\subsection{Adding Items}
Adding an item to the dictionary is done by using a new index key and assigning a value to it:\\
\includegraphics[width=10cm]{image1.jpg/adding_item.png}\\
\subsection{Removing Items}
There are several methods to remove items from a dictionary:\\
\includegraphics[width=10cm]{image1.jpg/remove_dict.png}\\
\subsection{Copy a Dictionary}
You cannot copy a dictionary simply by typing dict2 = dict1, because: dict2 will only be a reference to dict1, and changes made in dict1 will automatically also be made in dict2.\par
There are ways to make a copy, one way is to use the built-in Dictionary method copy().\\
\includegraphics[width=10cm]{image1.jpg/copy_dict.png}
\subsection{Nested Dictionary}
A dictionary can also contain many dictionaries, this is called nested dictionaries.\\
\includegraphics[width=10cm]{image1.jpg/nested_dict.png}\\
\section{Dictionary Methods}
\begin{table}[h!]
\centering
\includegraphics[width=10cm]{image1.jpg/dict_methods.png}
\caption{Dictionary Methods}
\label{tab:Dictionary Methods}
\end{table}
\newpage
\chapter{Python If ... Else}
\subsection{Python Conditions and If statements}
Python supports the usual logical conditions from mathematics:\\
\begin{itemize}
\item Equals: a == b
\item Not Equals: a != b
\item Less than: a < b
\item Less than or equal to: a <= b
\item Greater than: a > b
\item Greater than or equal to: a >= b
\end{itemize}
These conditions can be used in several ways, most commonly in "if statements" and loops.\par
An "if statement" is written by using the if keyword.\newline
\includegraphics[width=10cm]{image1.jpg/if.png}\\
In this example we use two variables, a and b, which are used as part of the if statement to test whether b is greater than a. As a is 33, and b is 200, we know that 200 is greater than 33, and so we print to screen that "b is greater than a".\\
\begin{figure}
\centering
\includegraphics{image1.jpg/if_loopop.jpg}\\
\caption{If Condition}
\label{fig:If Condition}
\end{figure}
\subsection{Elif}
The elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition".\\
\includegraphics[width=10cm]{image1.jpg/elif.png}\\
In this example a is equal to b, so the first condition is not true, but the elif condition is true, so we print to screen that "a and b are equal".\\
\subsection{Else}
The else keyword catches anything which isn't caught by the preceding conditions.\\
\includegraphics[width=10cm]{image1.jpg/else.png}\\
\begin{figure}
\centering
\includegraphics{image1.jpg/if_loop.jpg}
\caption{If-Else Condition}
\label{fig:If-Else Condition}
\end{figure}
In this example a is greater than b, so the first condition is not true, also the elif condition is not true\par
\newpage
\chapter{Python Loops}
Python has two primitive loop commands:
\begin{itemize}
\item While Loops
\item For Loops
\end{itemize}
\section{The while Loop}
Here, statement(s) may be a single statement or a block of statements with uniform indent. The condition may be any expression, and true is any non-zero value. \par
The loop iterates while the condition is true. Python, 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. \\
\begin{figure}
\centering
\includegraphics{image1.jpg/while.jpg}\\
\caption{While Loop}
\label{fig:While Loop}
\end{figure}
\newpage
\section{The break Statement}
The break statement is used for premature termination of the current loop. After abandoning the loop, execution at the next statement is resumed, just like the traditional break statement in C.\par
The most common use of break is when some external condition is triggered requiring a hasty exit from a loop. The break statement can be used in both while and for loops.\newline
\begin{figure}
\centering
\includegraphics{image1.jpg/break.jpg}
\caption{Break}
\label{fig:Break}
\end{figure}
\section{For Loops}
A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
This is less like the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages.\par
With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.\par
\begin{figure}
\centering
\includegraphics{image1.jpg/for.jpg}
\caption{For Loops}
\label{fig:For Loops}
\end{figure}
\newpage
\chapter{Python 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. \par
As you already know, Python gives you many built-in functions like print(), etc. but you can also create your own functions. These functions are called user-defined functions. \par
\section{Defining a Function }
You can define functions to provide the required functionality. Here are simple rules to define a function in Python. \par
\begin{itemize}
\item Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).
\item Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.
\item The first statement of a function can be an optional statement - the documentation string of the function or docstring.
\item The code block within every function starts with a colon (:) and is indented.
\item The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None.
\end{itemize}
\section{Recursion}
Python also accepts function recursion, which means a defined function can call itself.\par
Recursion is a common mathematical and programming concept. It means that a function calls itself. This has the benefit of meaning that you can loop through data to reach a result.\par
The developer should be very careful with recursion as it can be quite easy to slip into writing a function which never terminates, or one that uses excess amounts of memory or processor power. However, when written correctly recursion can be a very efficient and mathematically-elegant approach to programming.\par
In this example is a function that we have defined to call itself ("recurse"). We use the k variable as the data, which decrements (-1) every time we recurse. The recursion ends when the condition is not greater than 0 (i.e. when it is 0).\par
To a new developer it can take some time to work out how exactly this works, best way to find out is by testing and modifying it.\par
\newpage
\chapter{Python Classes and Object}
\section{Class }
Compared with other programming languages, Python’s class mechanism adds classes with a minimum of new syntax and semantics. It is a mixture of the class mechanisms found in C++ and Modula-3. Python classes provide all the standard features of Object Oriented Programming: the class inheritance mechanism allows multiple base classes, a derived class can override any methods of its base class or classes, and a method can call the method of a base class with the same name. Objects can contain arbitrary amounts and kinds of data. As is true for modules, classes partake of the dynamic nature of Python: they are created at runtime, and can be modified further after creation.\\
In C++ terminology, normally class members (including the data members) are public (except see below Private Variables), and all member functions are virtual. As in Modula-3, there are no shorthands for referencing the object’s members from its methods: the method function is declared with an explicit first argument representing the object, which is provided implicitly by the call. As in Smalltalk, classes themselves are objects. This provides semantics for importing and renaming. Unlike C++ and Modula-3, built-in types can be used as base classes for extension by the user. Also, like in C++, most built-in operators with special syntax (arithmetic operators, subscripting etc.) can be redefined for class instances.\\
(Lacking universally accepted terminology to talk about classes, I will make occasional use of Smalltalk and C++ terms. I would use Modula-3 terms, since its object-oriented semantics are closer to those of Python than C++, but I expect that few readers have heard of it.)\\
\includegraphics[width=10cm]{image1.jpg/classs.png}\\
\section{Class Object}
Class objects support two kinds of operations: attribute references and instantiation.\\
Attribute references use the standard syntax used for all attribute references in Python: obj.name. Valid attribute names are all the names that were in the class’s namespace when the class object was created. So, if the class definition looked like this:\\
\includegraphics[width=10cm]{image1.jpg/object.png}\\
\chapter{Inheritance}
Inheritance allows us to define a class that inherits all the methods and properties from another class.\\
Parent class is the class being inherited from, also called base class.\\
Child class is the class that inherits from another class, also called derived class.\\
The name BaseClassName must be defined in a scope containing the derived class definition. In place of a base class name, other arbitrary expressions are also allowed. This can be useful, for example, when the base class is defined in another module:\newline
Execution of a derived class definition proceeds the same as for a base class. When the class object is constructed, the base class is remembered. This is used for resolving attribute references: if a requested attribute is not found in the class, the search proceeds to look in the base class. This rule is applied recursively if the base class itself is derived from some other class.\\
There’s nothing special about instantiation of derived classes: DerivedClassName() creates a new instance of the class. Method references are resolved as follows: the corresponding class attribute is searched, descending down the chain of base classes if necessary, and the method reference is valid if this yields a function object.\\
Derived classes may override methods of their base classes. Because methods have no special privileges when calling other methods of the same object, a method of a base class that calls another method defined in the same base class may end up calling a method of a derived class that overrides it. (For C++ programmers: all methods in Python are effectively virtual.)\\
An overriding method in a derived class may in fact want to extend rather than simply replace the base class method of the same name. There is a simple way to call the base class method directly: just call BaseClassName.methodname(self, arguments). This is occasionally useful to clients as well. (Note that this only works if the base class is accessible as BaseClassName in the global scope.)\\
\includegraphics[width=10cm]{image1.jpg/inheritance.png}\\
\chapter{OOP's Terminology}
\begin{itemize}
\item \textbf{Class} : \descriptionlabel{A user-defined prototype for an object that defines a set of attributes that characterize any object of the class. The attributes are data members (class variables and instance variables) and methods, accessed via dot notation. }
\item \textbf{Class Variable} : \descriptionlabel{A variable that is shared by all instances of a class. Class variables are defined within a class but outside any of the class's methods. Class variables are not used as frequently as instance variables are. }
\item \textbf{Data Member} : \descriptionlabel{A class variable or instance variable that holds data associated with a class and its objects. }
\item \textbf{Function overloading} : \descriptionlabel{The assignment of more than one behavior to a particular function. The operation performed varies by the types of objects or arguments involved. }
\item \textbf{Instance Variable} : \descriptionlabel{A variable that is defined inside a method and belongs only to the current instance of a class. }
\item \textbf{Inheritance} : The transfer of the characteristics of a class to other classes that are derived from it.
\item \textbf{Object} : \descriptionlabel{A unique instance of a data structure that is defined by its class. An object comprises both data members (class variables and instance variables) and methods. }
\newpage
\end{itemize}
\chapter{Python Module}
If you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program, you are better off using a text editor to prepare the input for the interpreter and running it with that file as input instead. This is known as creating a script. As your program gets longer, you may want to split it into several files for easier maintenance. You may also want to use a handy function that you’ve written in several programs without copying its definition into each program.\par
To support this, Python has a way to put definitions in a file and use them in a script or in an interactive instance of the interpreter. Such a file is called a module; definitions from a module can be imported into other modules or into the main module (the collection of variables that you have access to in a script executed at the top level and in calculator mode).\par
\includegraphics[width=10cm]{image1.jpg/module.png}
\subsection{Module Search Path}
When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:\par
the directory containing the input script (or the current directory).
PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).
the installation-dependent default.\par
After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.\par
\subsection{Built-in Module}
Python comes with a library of standard modules, described in a separate document, the Python Library Reference (“Library Reference” hereafter). Some modules are built into the interpreter; these provide access to operations that are not part of the core of the language but are nevertheless built in, either for efficiency or to provide access to operating system primitives such as system calls. The set of such modules is a configuration option which also depends on the underlying platform. For example, the winreg module is only provided on Windows systems. One particular module deserves some attention: sys, which is built into every Python interpreter. The variables sys.ps1 and sys.ps2 define the strings used as primary and secondary prompts:\par
\includegraphics[width=10cm]{image1.jpg/built_in.png}\newline
\newline
Each module has its own private symbol table, which is used as the global symbol table by all functions defined in the module. Thus, the author of a module can use global variables in the module without worrying about accidental clashes with a user’s global variables. On the other hand, if you know what you are doing you can touch a module’s global variables with the same notation used to refer to its functions, modname.itemname.\newline
Modules can import other modules. It is customary but not required to place all import statements at the beginning of a module (or script, for that matter). The imported module names are placed in the importing module’s global symbol table.\newline
There is a variant of the import statement that imports names from a module directly into the importing module’s symbol table. \\
\newpage
\chapter{DJANGO -Basics}
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Django makes it easier to build better web apps quickly and with less code.\par
\section{History Of Django}
\begin{itemize}
\item \textbf{2003} : \descriptionlabel{Started by Adrian Holovaty and Simon Willison as an internal project at the Lawrence Journal-World newspaper}
\item \textbf{2005} : \descriptionlabel{Released July 2005 and named it Django, after the jazz guitarist Django Reinhardt.}
\item \textbf{2005} : \descriptionlabel{Mature enough to handle several high-traffic sites.}
\item \textbf{Current} : \descriptionlabel{Django is now an open source project with contributors across the world}
\end{itemize}
\section{Advanatges of Django}
Here are few advantages of using Django which can be listed out here \\
\begin{itemize}
\item Django provides a bridge between the data model and the database engine, and supports a large set of database systems including MySQL, Oracle, Postgres, etc. Django also supports NoSQL database through Django-nonrel fork. For now, the only NoSQL databases supported are MongoDB and google app engine.
\item Django supports multilingual websites through its built-in internationalization system. So you can develop your website, which would support multiple languages.
\item Django has built-in support for Ajax, RSS, Caching and various other frameworks.
\item Django provides a nice ready-to-use user interface for administrative activities.
\item Django comes with a lightweight web server to facilitate end-to-end application development and testing .
\end{itemize}
\section{Django-Enviroment}
Django development environment consists of installing and setting up Python, Django, and a Database System. Since Django deals with web application, it's worth mentioning that you would need a web server setup as well.\par
\title{Step 1 – Installing Python}
Django is written in 100 percent pure Python code, so you'll need to install Python on your system. Latest Django version requires Python 2.6.5 or higher for the 2.6.x branch or higher than 2.7.3 for the 2.7.x branch.\par
If you're on one of the latest Linux or Mac OS X distribution, you probably already have Python installed. You can verify it by typing python command at a command prompt. If you see something like this, then Python is installed.\par
\title{Step 2 - Installing Django}
Installing Django is very easy, but the steps required for its installation depends on your operating system. Since Python is a platform-independent language, Django has one package that works everywhere regardless of your operating system.
You can download the latest version of Django from the link http://www.djangoproject.com/download.\par
\title{Step 3 – Database Setup}
Django supports several major database engines and you can set up any of them based on your comfort.\\
\begin{itemize}
\item MySQL (http://www.mysql.com/)
\item PostgreSQL (http://www.postgresql.org/)
\item SQLite 3 (http://www.sqlite.org/)
\item MongoDb (https://django-mongodb-engine.readthedocs.org)
\end{itemize}
\title{Step 4 – Web Server}
Django comes with a lightweight web server for developing and testing applications. This server is pre-configured to work with Django, and more importantly, it restarts whenever you modify the code.\par
However, Django does support Apache and other popular web servers such as Lighttpd. We will discuss both the approaches in coming chapters while working with different examples.\par
\begin{figure}
\centering
\includegraphics{image1.jpg/django.png}
\caption{Django WebServer}
\label{fig:Django WebServer}
\end{figure}
\section{Creating Models}
A model is the single, definitive source of truth about your data. It contains the essential fields and behaviors of the data you’re storing. Django follows the DRY Principle. The goal is to define your data model in one place and automatically derive things from it.\par
This includes the migrations - unlike in Ruby On Rails, for example, migrations are entirely derived from your models file, and are essentially just a history that Django can roll through to update your database schema to match your current models.\\
\includegraphics[width=10cm]{image1.jpg/models.png}\\
\begin{thebibliography}{9}
\addcontentsline{toc}{chapter}{\numberline{}Bibliography}%
\bibitem{latexcompanion}
W3School
\textit{The \LaTeX\ Companion}.
Addison-Wesley, Reading, Massachusetts, 1993.
\bibitem{Python Documentation}
Python Documentation
\end{thebibliography}
\end{flushleft}
\end{document}