0% found this document useful (0 votes)
2 views10 pages

Python Advanced Concepts

python advanced concepts (2)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

Python Advanced Concepts

python advanced concepts (2)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Advanced

Concepts in
Python
Advanced Concepts in Python
[Link] Programming
[Link] Programming
[Link] Programming
[Link] Programming
[Link] Programming

PYTHON ADVANCED CONCEPTS Nov 19, 2025


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]])
>>> [Link]
(3, 5)
>>> [Link]
2
>>> [Link]
'int32‘
>>> [Link]
15
>>> type(a)
[Link]
PYTHON ADVANCED CONCEPTS Nov 19, 2025
Graphics Programming
Circle Example

from graphics import *


win=GraphWin("Circle",300,300)
pt=Point(200,200)
[Link]("yellow")
[Link](win)
cir=Circle(pt,55)
[Link]("blue")
[Link](“pink")
[Link](win)
[Link]()
[Link]()

PYTHON ADVANCED CONCEPTS Nov 19, 2025


Network Programming
Server Program
import socket # Import socket module

s = [Link]() # Create a socket object


host = [Link]() # Get local machine name
port = 12345 # Reserve a port for your service.
[Link]((host, port)) # Bind to the port

[Link](5) # Now wait for client connection.


while True:
c, addr = [Link]() # Establish connection with client.
print 'Got connection from', addr
[Link]('Thank you for connecting')
[Link]() # Close the connection

PYTHON ADVANCED CONCEPTS Nov 19, 2025


Network Programming
Client Program
import socket # Import socket module

s = [Link]() # Create a socket


objecthost = [Link]() # Get local machine name
port = 12345 # Reserve a port for your service.
[Link]((host, port))
print [Link](1024)
[Link]( ) # Close the socket when done

Run Server and Client


$ python [Link] # Once server is started run client as follows:
$ python [Link]

This would produce following result:


Got connection from ('[Link]', 48437)
Thank you for connecting
PYTHON ADVANCED CONCEPTS
Nov 19, 2025
GUI Programming
#Example for Button

import Tkinter
import tkMessageBox
top = [Link]()

def helloCallBack():
[Link]( "Hello Python", "Hello World")
B = [Link](top, text ="Hello", command = helloCallBack)
[Link]()
[Link]()

PYTHON ADVANCED CONCEPTS


Nov 19, 2025
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>

PYTHON ADVANCED CONCEPTS


Nov 19, 2025
Web Programming
hello_get.py
import cgi, cgitb
# Create instance of FieldStorage
form = [Link]()
# Get data from fields
first_name = [Link]('first_name')
last_name = [Link]('last_name')
print "Content-type:text/html\r\n\r\n"
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
Nov 19, 2025
PYTHON ADVANCED CONCEPTS

You might also like