This document provides an introduction to the Python programming language. It discusses why Python is used, what Python can be used for, its technical strengths, and its few downsides. It also provides instructions on installing Python and running a simple "Hello World" program. The key points are that Python is readable, maintainable, and has a small code size; it can be used for systems programming, GUIs, scripting, databases, and more; and its main downside is potential slower execution speed compared to compiled languages like C and C++.
Why do peopleuse Python?
• Software Quality:
Python is designed to be readable, and hence maintainable.
• Developer productivity:
Python code is typically 1/3 to 1/5 the size of equivalent C++ or JAVA
code
3.
What can Ido with Python?
• System Programming
• GUIs
• Internet Scripting
• Database Programming
• Games, Images, AI, XML and more
4.
What are Python’sTechnical Strength
• It’s OO
• It’s free
• It’s Portable
• It’s Powerful
• It’s Easy to use
• It’s Easy to learn
5.
What is theDownside of Python?
• Perhaps the only downside to Python is that the execution speed
may not always as fast as compiled languages such as C and C++
• Python is not compiled all the way down to binary machine code, it
compiled to byte code instead.
6.
Who Uses PythonToday?
• Google and Yahoo currently use Python in Internet service
• IBM use Python for hardware testing
• Industrial Light and Magic use Python in the production of movie
animation
• For more details, visit www.python.org
7.
Install Python
• Goto http://www.python.org/download/releases/3.2/ and
download Python3.2, then select Windows x86 MSI Installer
(3.2) or Windows X86-64 MSI Installer (3.2)
8.
Install Python
• Oryou can search for Python, choose “Download” and then
select Python 3.2 Windows x86 MSI Installer or Python 3.2
Windows X86-64 MSI Installer
9.
Hello World Program
•Implement by three different languages
• In C
• In JAVA
• In Python
• Python commandprint – Displays data, values, and expressions
• The single and double quotation mark string objects, which are
collections of texts surrounded by quotes.
Some Python commands
>>> width =20
>>> height = 45
>>> area = width * height
>>> area
900
Declare a variable and assign its
value Example: Area of a
rectangle
18.
>>> a=3
>>> b=4
>>>a+1
>>> b*3
>>> b/3
>>> b/3.0
>>> b**2
>>> 2+4.0
>>> 2.0**b
What are the outputs? Why?
19.
How do yourun programs?
Three different methods:
• 1. Interactive Coding
• 2. Files (such as NotePad, WordPad)
• 3. Integrated Development Environment (IDE)
20.
Create and runa program in the
Python IDLE
• From File -> New Window
• Type your program
print ("Hello, World! ")
• Save your program
(Give a name you like, such as test.py)
• Run the program
(by selecting the Run Module or pressing the F5 key)
21.
Your first Pythonprogram- hello.py
# This program says hello and asks for my name.
hello = 'Hello world! '
print(hello)
print('What is your name?')
myName = input()
print('It is good to meet you, ' + myName)
22.
hello.py executed sequentially
#This program says hello and asks for my name.
Any text following a # sign is a comment. Comments are not
for the computer, but for you, the programmer.
1.hello = 'Hello world! ' # assign the string to a name
2.print(hello) # call the print( ) function
3.print('What is your name?') # call the print( ) function
4.myName = input() # call the input( ) function
5.print('It is good to meet you, ' + myName)