Introduction to Python


Contents

How to install Python on Linux
How to run a Python program
The basic of Python codes
Data expressions
Built-in functions in Python
Interactive input/output
Conditional statement for Python
Loop structure for Python
Creating your own functions
Python modules
Reading/writing files for Python
Error handling code
Object Oriented Programming (OOP)
Tkinter package for GNU programming


Interactive input/output

The command, raw_input(), asks a question, and displays what you answer.
print raw_input("What is your name? ")
$ What is your name? Megan
$ Megan
The above can be arranged as follows:
name=raw_input("What is your name?")
print "Hi %s. Nice to meet you." %name
$ What is your name? Megan
$ Hi Megan. Nice to meet you.
Input() also takes numbers as a methematical value.
const=input("Input some number.")
for i in range(3):
  print "%d*%d=%d" %(const,i,i*const)
$ Input some number.5
$ 5*0=0
$ 5*1=5
$ 5*2=10



Back to Electronics Page

Back to Hiro's Physics Main