You are on page 1of 19

Python

Overview
What is Python?
Created in 1990 by Guido van Rossum
• About the origin of Python, Van Rossum wrote in 1996:
• Over six years ago, in December 1989, I was looking for a
"hobby" programming project that would keep me occupied
during the week around Christmas. My office ... would be
closed, but I had a home computer, and not much else on
my hands. I decided to write an interpreter for the new
scripting language I had been thinking about lately: a
descendant of ABC that would appeal 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).
Why Use Python?
• Clean, clear syntax
• Very few keywords
• Highly portable laptops , radios, watches(able to be carried
or moved easily, (of software, files, etc) able to be transferred
from one type of computer system to another.)
• Runs almost anywhere - high end servers
• server, network computer, computer program, or device that
processes requests from a client On the World Wide Web, for
example, a Web server is a computer that uses the HTTP
Hypertext Transfer Protocol protocol to send Web pages to a
client's computer when the client requests them manage
network resources
• HTTP (Hypertext Transfer Protocol) gives users a way to interact
with web resources such as HTML files by transmitting
hypertext messages between clients and servers. HTTP clients
generally use Transmission Control Protocol (TCP) connections to
communicate with servers.
Extensible
• Designed to be extensible using C/C++ allowing access to
many external libraries
Productivity !
• Reduce Development Time
• Code is 2-lOx shorter than C, C++, Java

• Improve Program Maintenance


• Code is extremely readable

• Less Training
• Language is very easy to learn
Python VS Java
• Code 5-10 times more concise
• Dynamic typing (when the majority of its type
checking is performed at run-time as opposed to
at compile-time. In dynamic typing, types are
associated with values not variables.)
• Much quicker development
• less typing
• Yes, it runs slower
• but development is so much faster!
• Use Python with Java: Jython!
Python
Basics
Python Programs
• Python modules and programs are differentiated
only by the way they are called

• .py files executed directly are programs (often


referred to as scripts)

• .py files referenced via the import statement are


modules
• The __init__.py files are required to make Python
treat the directories as containing packages;
Python Blocks
• Blocks are delimited by indentation(mark the
beginning and end of the embedded block-
structured statements.)
• Colon used to start a block (:)
• Tabs or spaces may be used
• Many hate this when they first see it
• Humans use indentation when reading code to
determine block structure
Python Block Example
• In most of other Languages
if(a>b){//Code to be Executed..!}

• In Python
if a>b:
//First Line of Block
//Second one
//Thrid one
These Code are out of block
Python Function
• Functions are defined with def statement:
• Functions are reusable blocks which can be reuse
• Function can be called with different inputs (parameters/arguments) A
parameter is the variable listed inside the parentheses in the function
definition. An argument is the value that are sent to the function when it is
called.
• Functions are not executes until they called
• def myfunction(a,b):
//First Line
//Second Line
• In above example a function is defined named as “myfunction” with two
Parameters.
• Functions can be with or without parameters.
Function

Parameters
can you find it some errors in this code?
Python 3.10.5 (main, Jul 22 2022, 17:09:35) [GCC 9.4.0] on linuxType "help", "copyright", "credits" or
"license" for more information.>>>
def_functionTraceback (most recent call last): File "<stdin>", line 1, in <module>NameError: name
'def_function' is not defined>>> >>>
def_fname()Traceback (most recent call last): File "<stdin>", line 1, in <module>NameError: name
'def_fname' is not defined>>>
def my_function():... my_variable111=10 File "<stdin>", line 2 my_variable111=10 ^IndentationError:
expected an indented block after function definition on line 1>>>
my_ variable = 10 File "<stdin>", line 1 my_ variable = 10 ^^^^^^^^ SyntaxError: invalid syntax >>>
my_variable= 10 >>> print "all my_function variable!" File "<stdin>", line 1 print "all my_function variable!"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean
print(...)? >>>
print ("all my_function variable!")
all my_function variable!>>>

Correct path

def my_function():
my_variable= 10
print ("all my_function variable!")
Installation of Python
• Open the URL listed blow:
https://www.python.org/downloads/
• Download the Latest version of python for your OS
• Install it on your OS
• It will configure it automatically for your OS
• Visit this URL for more Details

https://www.youtube.com/watch?v=uDbDIhR76H4&ab_cha
nnel=AmitThinks
• Use IDLE Python Editor for write Python Programs, it
comes with python package and install along with this
package
Hello World ! with Python
• Use Print Command to Print any String on Screen

• Here you succeed to write your first program in python.


More Information Python
• Comes with extensive documentation,
including tutorials and library reference
• Visit www.python.org for more details
More Information on Python
• Comes with extensive documentation,
including tutorials and library e
• Also a number of Python books available
referenc
• Visit www p y t h o n . org for more details
• Can. find python tutorial and reference manual

You might also like