SlideShare a Scribd company logo
Advanced Concepts in Python
Advanced Concepts in Python
1.Scientific Programming
2.Graphics Programming
3.Network Programming
4.GUI Programming
5.Web Programming
Scientific Programming
An example----Numpy provides Mathematical Functions
>>> from numpy import *
>>> a = arange(15).reshape(3, 5)
>>> a
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
>>> a.shape
(3, 5)
>>> a.ndim
2
>>> a.dtype.name
'int32‘
>>> a.size
15
>>> type(a)
numpy.ndarray
Graphics Programming
Circle Example
from graphics import *
win=GraphWin("Circle",300,300)
pt=Point(200,200)
pt.setOutline("yellow")
pt.draw(win)
cir=Circle(pt,55)
cir.setOutline("blue")
cir.setFill(“pink")
cir.draw(win)
win.getMouse()
win.close()
Network Programming
Server Program
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
s.bind((host, port)) # Bind to the port
s.listen(5) # Now wait for client connection.
while True:
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
c.send('Thank you for connecting')
c.close() # Close the connection
Network Programming
Client Program
import socket # Import socket module
s = socket.socket() # Create a socket
objecthost = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
s.connect((host, port))
print s.recv(1024)
s.close( ) # Close the socket when done
Run Server and Client
$ python server.py # Once server is started run client as follows:
$ python client.py
This would produce following result:
Got connection from ('127.0.0.1', 48437)
Thank you for connecting
GUI Programming
#Example for Button
import Tkinter
import tkMessageBox
top = Tkinter.Tk()
def helloCallBack():
tkMessageBox.showinfo( "Hello Python", "Hello World")
B = Tkinter.Button(top, text ="Hello", command = helloCallBack)
B.pack()
top.mainloop()
Web Programming
#Example for Button
<form action="/cgi-bin/hello_get.py" method="get">
First Name: <input type="text" name="first_name"> <br />
Last Name: <input type="text" name="last_name" />
<input type="submit" value="Submit" />
</form>
Web Programming
hello_get.py
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
first_name = form.getvalue('first_name')
last_name = form.getvalue('last_name')
print "Content-type:text/htmlrnrn"
print "<html>"
print "<head>"
print "<title>Hello - Second CGI Program</title>"
print "</head>"
print "<body>"
print "<h2>Hello %s %s</h2>" % (first_name, last_name)
print "</body>” print "</html>“
This would generate the following result:
Hello ShanmugaPriyan NandhanaShri
Advanced Concepts in Python

More Related Content

PDF
Numpy python cheat_sheet
PDF
NumPy Refresher
PPTX
Image processing lab work
PPTX
Python programing
PDF
Effective Numerical Computation in NumPy and SciPy
PDF
Array and pointer
KEY
Pointer Events in Canvas
PDF
Basics of Computer graphics lab
Numpy python cheat_sheet
NumPy Refresher
Image processing lab work
Python programing
Effective Numerical Computation in NumPy and SciPy
Array and pointer
Pointer Events in Canvas
Basics of Computer graphics lab

What's hot (20)

PPTX
Deep learning study 3
PDF
Numpy tutorial(final) 20160303
DOCX
Computer graphics
PDF
Evolving Search Relevancy: Presented by James Strassburg, Direct Supply
KEY
ARTDM 170, Week 13: Text Elements + Arrays
PDF
C Graphics Functions
PPTX
Mat lab lecture part 1
PPT
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
PDF
Introduction to NumPy (PyData SV 2013)
PPTX
Introduction to graphics programming in c
PDF
Program Language - Fall 2013
DOC
Seg code
DOCX
PythonArtCode
PDF
Intoduction to numpy
PPT
Lecture on graphics
PDF
Computer graphics lab manual
DOCX
Dwi putri erlinda saraswati
PDF
Introduction to NumPy for Machine Learning Programmers
PDF
Corner Stitching in Swift @ Base Labs - Krakow
PDF
2Bytesprog2 course_2014_c9_graph
Deep learning study 3
Numpy tutorial(final) 20160303
Computer graphics
Evolving Search Relevancy: Presented by James Strassburg, Direct Supply
ARTDM 170, Week 13: Text Elements + Arrays
C Graphics Functions
Mat lab lecture part 1
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Introduction to NumPy (PyData SV 2013)
Introduction to graphics programming in c
Program Language - Fall 2013
Seg code
PythonArtCode
Intoduction to numpy
Lecture on graphics
Computer graphics lab manual
Dwi putri erlinda saraswati
Introduction to NumPy for Machine Learning Programmers
Corner Stitching in Swift @ Base Labs - Krakow
2Bytesprog2 course_2014_c9_graph
Ad

Similar to Advanced Concepts in Python (20)

PDF
Clustering com numpy e cython
PPTX
Python 표준 라이브러리
PPTX
2.3 SciPy library explained detialed 1.pptx
PDF
Python for Scientific Computing -- Ricardo Cruz
PPTX
Python 03-parameters-graphics.pptx
PPTX
Array matrix example programs - C language
PPTX
Java arrays
PPT
Computer Programming- Lecture 9
PPTX
Python Cheat Sheet Presentation Learning
PDF
Pandas numpy Related Presentation.pptx.pdf
PPTX
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
PDF
SCIPY-SYMPY.pdf
PDF
Write Python for Speed
PPTX
Presentation1 computer shaan
PPTX
Week_02_Lec_ Java Intro continueed..pptx
PDF
Informatics Practices (new) solution CBSE 2021, Compartment, improvement ex...
PDF
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
PPTX
Федор Поляков (Looksery) “Face Tracking на мобильных устройствах в режиме реа...
PDF
Python matplotlib cheat_sheet
PDF
Using the code below- I need help with creating code for the following.pdf
Clustering com numpy e cython
Python 표준 라이브러리
2.3 SciPy library explained detialed 1.pptx
Python for Scientific Computing -- Ricardo Cruz
Python 03-parameters-graphics.pptx
Array matrix example programs - C language
Java arrays
Computer Programming- Lecture 9
Python Cheat Sheet Presentation Learning
Pandas numpy Related Presentation.pptx.pdf
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
SCIPY-SYMPY.pdf
Write Python for Speed
Presentation1 computer shaan
Week_02_Lec_ Java Intro continueed..pptx
Informatics Practices (new) solution CBSE 2021, Compartment, improvement ex...
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Федор Поляков (Looksery) “Face Tracking на мобильных устройствах в режиме реа...
Python matplotlib cheat_sheet
Using the code below- I need help with creating code for the following.pdf
Ad

More from Saraswathi Murugan (7)

PPTX
Data mining in e commerce
PPTX
Data mining
PPTX
PHP Basics
PPTX
Python modulesfinal
PPTX
National Identity Elements of India
PPTX
Pythonppt28 11-18
PPTX
FUNDAMENTALS OF PYTHON LANGUAGE
Data mining in e commerce
Data mining
PHP Basics
Python modulesfinal
National Identity Elements of India
Pythonppt28 11-18
FUNDAMENTALS OF PYTHON LANGUAGE

Recently uploaded (20)

PPTX
GDM (1) (1).pptx small presentation for students
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
01-Introduction-to-Information-Management.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharma ospi slides which help in ospi learning
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Structure & Organelles in detailed.
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
GDM (1) (1).pptx small presentation for students
Supply Chain Operations Speaking Notes -ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Microbial diseases, their pathogenesis and prophylaxis
VCE English Exam - Section C Student Revision Booklet
Microbial disease of the cardiovascular and lymphatic systems
01-Introduction-to-Information-Management.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
O5-L3 Freight Transport Ops (International) V1.pdf
Insiders guide to clinical Medicine.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPH.pptx obstetrics and gynecology in nursing
Pharma ospi slides which help in ospi learning
102 student loan defaulters named and shamed – Is someone you know on the list?
RMMM.pdf make it easy to upload and study
Cell Structure & Organelles in detailed.
Abdominal Access Techniques with Prof. Dr. R K Mishra

Advanced Concepts in Python

  • 2. Advanced Concepts in Python 1.Scientific Programming 2.Graphics Programming 3.Network Programming 4.GUI Programming 5.Web Programming
  • 3. Scientific Programming An example----Numpy provides Mathematical Functions >>> from numpy import * >>> a = arange(15).reshape(3, 5) >>> a array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) >>> a.shape (3, 5) >>> a.ndim 2 >>> a.dtype.name 'int32‘ >>> a.size 15 >>> type(a) numpy.ndarray
  • 4. Graphics Programming Circle Example from graphics import * win=GraphWin("Circle",300,300) pt=Point(200,200) pt.setOutline("yellow") pt.draw(win) cir=Circle(pt,55) cir.setOutline("blue") cir.setFill(“pink") cir.draw(win) win.getMouse() win.close()
  • 5. Network Programming Server Program import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 12345 # Reserve a port for your service. s.bind((host, port)) # Bind to the port s.listen(5) # Now wait for client connection. while True: c, addr = s.accept() # Establish connection with client. print 'Got connection from', addr c.send('Thank you for connecting') c.close() # Close the connection
  • 6. Network Programming Client Program import socket # Import socket module s = socket.socket() # Create a socket objecthost = socket.gethostname() # Get local machine name port = 12345 # Reserve a port for your service. s.connect((host, port)) print s.recv(1024) s.close( ) # Close the socket when done Run Server and Client $ python server.py # Once server is started run client as follows: $ python client.py This would produce following result: Got connection from ('127.0.0.1', 48437) Thank you for connecting
  • 7. GUI Programming #Example for Button import Tkinter import tkMessageBox top = Tkinter.Tk() def helloCallBack(): tkMessageBox.showinfo( "Hello Python", "Hello World") B = Tkinter.Button(top, text ="Hello", command = helloCallBack) B.pack() top.mainloop()
  • 8. Web Programming #Example for Button <form action="/cgi-bin/hello_get.py" method="get"> First Name: <input type="text" name="first_name"> <br /> Last Name: <input type="text" name="last_name" /> <input type="submit" value="Submit" /> </form>
  • 9. Web Programming hello_get.py import cgi, cgitb # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields first_name = form.getvalue('first_name') last_name = form.getvalue('last_name') print "Content-type:text/htmlrnrn" print "<html>" print "<head>" print "<title>Hello - Second CGI Program</title>" print "</head>" print "<body>" print "<h2>Hello %s %s</h2>" % (first_name, last_name) print "</body>” print "</html>“ This would generate the following result: Hello ShanmugaPriyan NandhanaShri