Report For Python
Report For Python
Submitted to:
Mr. Pradeep Jha
Head of Dept.
CSE/IT/AI&DS
Acknowledgement
2
I express our indebtedness to Mr. Pradeep Jha, Head of Department of Computer
Science and Engineering/Information Technology/AI&DS, Global Institute of
Technology, Jaipur for providing me humble support during my Practical Training
period.
Without their support and timely guidance, the completion of our Practical Training
would have seemed a farfetched dream. In this respect I find myself lucky to have
mentors of such a great potential.
Student Name
Gaurav Garg
RTU Roll No.
21EGJCS046
B.Tech. III Semester, II Year, CSE
Abstract
3
sets. It’s popular inthe scientific community forscientific computing; there
are libraries thatmake it easy to share academic code projects in Python.
Python is aweb programming language, so it interfaces with the internet. It
knows how toreceive and send web requests andtalk to databases. This paper
describesthe main features of Python programming, loops and control
statements inpython then discusses applications of Python programming.
Certificate………………………………………………………………….I
Acknowledgement………………………………………………………...II
Abstract…………………………………………………………………...III
Contents:-
1. Introduction to webDevelopment
1.1 HTML……………………………………….………………….1
1.2 CSS……………………………………………………………..3
1.3 Javascript……………………………….……………………….5
2. Introduction
2.1 Python…………………………………………………………...…7
2.2 Scripting Language……………………………...…………...….…7
2.3 Object Oriented Programming……………………...……….….….7
2.4 History of Python………………………………….…………….…8
2.5 Behind the Scene of Python………………………….………….…8
4
3. Downloading and Installing Python
3.1 Downloading Python………………………………...……..….…9
3.2 Installing Python……………………………………...…………12
3.3 Setup path of variable…………………………………….………...14
3.4 Running The Python IDLE…………………………………........…15
3.5 Python Code Execution…………………………………………..…16
8. Conclusion…………………………………………………………..40
Reference………………………………………………………….………...43
5
6
LIST OF TABLES
7
LIST OF FIGURES
1.1HTML
The HyperText Markup Language or HTML is the standard markup language for
documents designed to be displayed in a web browser. It can be assisted by technologies
such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript.
HTML
(HyperText Markup Language)
9
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph</p>
</body>
</html>
10
1.1 CSS
Cascading Style Sheets (CSS) is a style sheet language used for describing the
presentation of a document written in a markup language such as HTML or XML . CSS is
a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
Format
There are three types of CSS which are given below:
Inline CSS.
Internal or Embedded CSS.
External CSS.
Rules
A CSS rule is a grouping of one or more CSS properties which are to be applied to one or
more target HTML elements. A CSS rule consists of a CSS selector and a set of CSS
properties. The CSS selector determines what HTML elements to target with the CSS
rule.
11
1.2Javascript
JavaScript often abbreviated JS, is a programming language that is one of the core
technologies of the World Wide Web, alongside HTML and CSS.[11] As of 2022, 98%
of websites use JavaScript on the client side for webpage behavior,[12] often
incorporating third-party libraries.[13] All major web browsers have a dedicated
JavaScript engine to execute the code on users devices.
.Paradigm
Multi-paradigm: event-driven, functional, imperative, procedural, object-oriented
programming.
. Designed by
Brendan Each of Netscape initially; others have also contributed to the ECMAScript
standard.
JavaScript engines were originally used only in web browsers, but are now core
components of some servers and a variety of applications. The most popular runtime
system for this usage is Node.js.
Although Java and JavaScript are similar in name, syntax, and respective standard
libraries, the two languages are distinct and differ greatly in design.
12
SYNTAX
Variables in JavaScript can be defined using either the var,[71] len[72] or const[73]
keywords. Variables defined without keywords will be defined at the global scope.
EXAMPLE
<html>
<head>
<script type="text/javascript">
function msg(){
alert("Hello java script");
}
</script>
</head>
<body>
<p>Welcome to JavaScript</p>
<form>
<input type="button" value="click" onclick="msg()"/>
</form>
</body>
</html>
<script type="text/javascript">
alert("Hello java script");
</script>
13
2.Introduction
2.1Python
2.2Scripting Language
14
2.3Object Oriented Programming
2.4History of python
Python was conceived in the late 1980s. and its implementation was started inDecember
1989 by Guido van Rossum at CWI in the Netherlands as a successor to the
ABClanguage (itself inspired by SE IL) capable of exception handling and interfacing
with theAmoeba operating system. Van Rossum is Python's principal author, and his
continuingcentral role in deciding the direction of Python is reflected in the title given to
him by the python community benevolent dictator for life (BDFL).
15
2.5 Behind the Scene of Python
About the origin of Python, Van Rossum wrote 1n 1996Over six years ago. in December
1989. I was looking for a hobbyprogramming project that would keep me occupied during
the week aroundChristmas. Mv office … would be closed. but I had a home Computer,
and nomuch else on my hands. I decided to write an interpreter for the new
scriptinglanguage I had been thinking about lately: a descendant of ABC that
wouldappeal to Unix/C hackers. I chose Python as a working title for the project,being in
a slightly irreverent mood (and a big fan of Monty Python's Flying circus).
If you don’t already have a copy of python installed on your computer , you will need to
open up your internet browser and go to the python download page
(http://www.python.org/download/).
Now that you are on the download page, select which of the software builds you would
like
to download. For the purposes of this article we will use the most up to date version
available (Python 3.9.1)
16
Once you have clicked on that, you will be taken to a page with a description of all the
newupdates and features of 3.9.1, however, you can always read that while the download
is inprocess. Scroll to the bottom of the page till you find the Download' section and click
onthe link that says "download page.
Now you will scroll all the way to the bottom of the page and find the "Windows installer
32 bit." If you want to download the 32-bit, feel free to do so. We believe that even if you
have a 64-bit operating system installed on your computer, the 64-bit is preferable. We
saythis because it will still run well and sometimes, with the 64-bit architectures, some of
thecompiled binaries and Python libraries don't work well.
Python 3.10. 3.10 is the newest major release of the Python programming
language, and it contains many new features and optimizations.
17
3.2Installing Python
Once you have downloaded the python 3.9.1 , simply navigate to the download location
on your computer , double clicking the file when the dialog box pops up. After starting
the installer , one of two options may be selected.
You will not need to be an administrator (unless a system update for the C Runtime
Library is required or you install the Python Launcher for Windows for all users)
-The Python Launcher for Windows will be installed according to the option at the
bottom of the first page
-The standard library, lest suite, launcher and pip will be installed
will allow you to select the features to install. the installation location and other options or
18
post-install actions. To install debugging symbols or binaries, you will need to use this
option.
To perform an all-users installation, you should select "Customize installation". In
this case
Python is widely considered among the easiest programming languages for beginners to
learn. If you're interested in learning a programming language, Python is a good place to
start. It's also one of the most widely used.
19
Now that you have completed the installation process , click on “close”.
Begin by opening the start menu and typing in "environment" and select the option called
Edit the system environment variables. When the "System Properties" window appears,
click on "Environment Variables.Once you have the "Environment Variables window
open, direct your focus to the bottomhalf. You will notice that it controls all the "System
20
Variables" rather than just thisassociated with your user. Click on "New”to create a new
variable for Python
Simply enter a name for your Path and the code shown below. For the purposes of
thisexample we have installed Python 3.9.1, so we will call the path "Pythonpath”.
The string that you will need to enter is: "\Program Files\Python39 \Scripts;"
21
3.4 Running The Python IDE
Now that we have successfully completed the installation process and added
our"Environment Variable." you are ready to create your first basic Python script. Let's
begin
22
by opening Python's by pressing "Start" and typing "Python" and selecting the "IDLE
(PYTHON 3.9 64-bit).”
Once the IDLE is open, we will begin by using the simplest directive possible. This is the
"print directive which simply prints whatever you tell it to, into a new line. Start by
typingprint directive like the one shown in the image below or copy and paste this text
then press
"Enter": print ("Industrial Training").
23
3.5 Python code execution
Python's traditional runtime execution model: source code you type istranslated to byte
code, which is then run by the Python Virtual Machine.
Data types determine whether an object can do something, or whether it just would not
make sense. Other programming languages often determinewhether an operation makes
sense for an object by making sure the object can never bestored somewhere where the
operation will be performed on the object (this type system iscalled static typing). Python
does not do that. Instead it stores the type of an object with theobject, and checks when
the operation is performed whether that operation makes sense for that objects (this is
called dynamic typing ).
Python has many native data types. Here are the important ones:
Booleans are either True or False.
Numbers can be integers (1 and 2), floats (1.1 and 1.2), fractions (1/2 and
2/3). or even complex numbers.
Strings are sequences of Unicode characters, e.g. an HTML document.
Bytes and byte arrays, e.g. a JPEG image file.
Lists are ordered sequences of values.
Tuples are ordered, immutable sequences of values.
Sets are unordered bags of values.
24
4.1.Variables
Variables are nothing but reserved memory locations to store values. This means that
whenyou create a variable you reserve some space in memory.Based on the data type of a
variable. the interpreter allocates memory and decides what canbe stored in the reserved
memory. Therefore. b assigning different data types to variables.you can store integers,
decimals or characters in these variables.
Ex:
counter = 100 # An integer assignment
miles = 1000.0 # A floating point
he = "John" # A string
Python variables are of four different types: Integer, Long Integer, Float, and String.
Integers are used to define numeric values; Long Integers are used for defining integers
with bigger lengths than a normal Integer.
Python supports four different numerical types − int (signed integers) long (long integers,
they can also be represented in octal and hexadecimal) float (floating point real values)
complex (complex numbers).
25
26
4.1 String
In programming terms, we usually call text a string. When you think a string as collection
of letters. the term makes senseAll the letters, numbers, and symbols in this book could be
a string.for that matter, your name could be a string, and so could yourAddressIn Python,
we create astring by putting quotesaround text. For example, we could take our
otherwise useless.
● Len("hello") 5 # size
Python Operators in general are used to perform operations on values and variables.
These are standard symbols used for the purpose of logical and arithmetic operations. In
this article, we will look into different types of Python operators.
Python divides the operators in the following groups: Arithmetic operators. Assignment
operators. Comparison operators.
27
4.4.1 Arithmetic operator
Operators in Python are used to execute or manipulate certain tasks. Python comparison
operators, also known by the name relational operators, are used in comparing two values
and to apply conditions respectively.
28
Table 4.2 : comparison operator
4.4.3Logical Operator
29
For example-
To access values in tuple, use the square brackets for slicing along with the index
o1indices to obtain value available at that index.
For example-
Tuples respond to the + and * operators much I1kc strings; they meanconcatenation and
repetition here too, except that the result is a new tuple, not astring. In fact, tuples respond
to all of the general sequence operations we used onstrings in the prior chapter-
30
5.1.3 Built in Tuple Functions
5.1 List
The list is a most versatile datatype available in Python which can be written as a 1s1
of comma-separated values (items) between square brackets. Important thing about a
list is that items in a list need not be of the same type. Creating a list is as simple as
putting different comma-separated values between square brackets.
For example –
Similar to string indices, list indices start at 0, and lists can be sliced,concatenated and so
on.
To access value in lists , use the square brackets for slicing along with the index or
indices to obtain value available at that index.
For example –
31
list2 = [1, 2, 3, 4, 5, 6,71;
print "list1[0]: ", list1[0]
print "list2[1:5]: ", list2[1:5]
Output:
List1[0]: physics
list2[1:5]: [2, 3, 4, 5]
Update:
list = ('physics', 'chemistry', 1997,2000]
print "Value available at index 2”
print list|2]
list[2] = 2001
print "New value available at index 2
print list|2]
output:
Value available at index 2: 44
New value available at index 2 : 2001
Delete:
List1 = ('physics', 'chemistry', 1997, 2000)
print list1
del list1[2]
print "After deleting value at index 2:
print list1
['physics', 'chemistry', 1997, 2000]
Output:
After deleting value at index 2 :
['physics', 'chemistry', 2000]
5.1.2Basic in Operation
5.1.3 Built in Functions & Methods
32
Python includes following list methods –
33
6.1.1Loops Definition
For loop:
34
>>> for mynum in [1, 2, 3, 4, 5]:
print "Hello", mynum
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
While loop:
>>>while( count<4)
print 'The count is:', count
count = count +
The count is:0
The count is:1
The count is:2
The count is:3
6.2Conditional Statement
35
Python programming language provides following types of decision making statements .
click the following links to check their detail.
If Statement.
>>> state = "Texas"
>>> It state ==
" Texas"
print "TX
TX
Else statement:
>>>it state
"Texas
Print "TY"
print " inferior state]"
If…Else…If Statement:
>›> it name ==
"Paige"
print "Hi Paige!"
en name =
"Walker":
print "Hi Walker!"
else:
print "Imposter!"
6.1.3Conditional Statement
36
IF-THEN , IF-THEN-ELSE , and IF-THEN-ELSIF.
6.3 Function
Python, a function is a group of related statements that performs a specific task. Functions
help break our program into smaller and modular chunks. As our program grows larger
and larger, functions make it more organized and manageable. Furthermore, it avoids
repetition and makes the code reusable.
To define a function, Python provides the def keyword. The following is the syntax of
defining a function. Syntax: def function_name(parameters): """docstring""" statement1
statement2 ... ...
Function blocks begin with the keyword def followed by the function name
andparentheses (wo).Any input parameters or arguments should be placed within
theseparentheses. You can also define parameters inside these parentheses. The first
statement of a function can be an optional statement – thedocumentation string of the
function. The code block within every unction starts with a colon (:) and 1S indented.The
statement return expression exits a unction, optionally passing back anexpression to the
caller. A return statement with no arguments is the same as returnNone.
37
As of now, the latest version of Python 3.8 has 69 built-in functions.
Syntax-
Example–
38
7. Uses & Scope
Python is a versatile programming language that can be used in a variety of fields, such as
software development, government administration, business, science, arts, education, and
others. According to Naukri.com, there were more than 75,000 open jobs for Python
developers in India at the end of 2019.
39
Science-
▪ Bioinformatics
System Administration-
● -Unix
● Web sphere
● Web logic
Testing Scripts-
● -unittest
Python lets the test automation engineer decide whether classes or functions should be
used for Selenium test automation.
- System programming
- Graphical User Interface Programming
- Internet Scripting
- Component Integration
40
- Database Programming
- Gaming, Images, XML., Robot and more
Python is used by Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase,
Spotify, and a number of other massive companies. It's one of the four main languages at
Google, while Google's YouTube is largely written in Python. Same with Reddit,
Pinterest, and Instagram.
41
- Structure supports such concepts as polymorphism, operation overloading
and multipleinheritance.
Indentation
Its powerful
- Dynamic typing
- Built-in types and tools
- Library utilities
- Third party utilities (e.g. Numeric, NumPy, SciPy)
- Automatic memory management
-
It's portable
Conclusion
I believe the trial has shown conclusively that it is both possible and
desirable to use Python as the principal teaching language –
42
- It is Free as in both cost and source code
-
-It is trivial to install on a Windows PC allowing students to taketheir
interest further. For many the hurdle of installing a rascal orC compileron
a Windows machine is either too expensive or tooComplicated.
CODE-
43
num1 = 1.5
num2 = 6.3
OUTPUT-
44
Reference
- https://www.grras.com/
- https://www.w3schools.com/python/
- https://www.udemy.com/
- https://www.programiz.com/python-programming/
- https://realpython.com/
45