Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Programming using Python

prutor.ai Amey Karkare


Dept. of CSE
IIT Kanpur

For any queries reach out to rahulgr@iitk.ac.in or rahulgarg@robustresults.com


or whatsapp 9910043510

1
Python Programming E&ICT IIT Kanpur
The Programming Cycle for Python

prutor.ai

2
Programming E&ICT IIT Kanpur
Run
with some input

Write/Edit

prutor.ai
OK?
NO
YES
YES
More
Inputs?
NO
3
Programming E&ICT IIT Kanpur
The Programming Cycle for Python
1. Write your program or edit (i.e., change
or modify) your program.

prutor.ai
2. Run your program on an input.
– Python is an interpreted language (unlike C,
C++, Java). There is no separate compilation
step.
3. If output is not correct, return to editing
step.
4. Repeat step 2,3 for other inputs, if any.
4
Programming E&ICT IIT Kanpur
An IDE for Python
• In this course, we recommend that you use
Spyder: an Integrated Development

prutor.ai
Environment (IDE) for Python.
• Spyder consists of
– Python shell (iPython)
– Editor
– Debugger (Object Inspector)

5
Programming E&ICT IIT Kanpur
Toolbar
Debugger/
Inspector

Editor
prutor.ai
iPython Shell

Spyder: Python IDE 6


Programming E&ICT IIT Kanpur
prutor.ai
User Program
Filename, preferred extension is py
7
Programming E&ICT IIT Kanpur
prutor.ai
Running the Program
8
Programming E&ICT IIT Kanpur
prutor.ai
Output in the shell

iPython Shell & Output


9
Programming E&ICT IIT Kanpur
prutor.ai
iPython Shell & Output
10
Programming E&ICT IIT Kanpur
IN[1]:
Welcome
to Python 3
IN[2]:

IN[3]:

IN[4]:
prutor.ai
( )

Python Shell is Interactive


11
Programming E&ICT IIT Kanpur
IN[1]: Python Shell Prompt
Welcome
to Python 3
IN[2]:
User Commands
IN[3]:

IN[4]:
prutor.ai
(
(Statements)

Outputs

Python Shell is Interactive


12
Programming E&ICT IIT Kanpur

You might also like