Introduction to Python Programming (2) Introduction to IDLE

S. Thater and A. Friedrich

Saarland University

Winter Semester 2011/2012

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 1 / 1 Integrated Developing Environments (IDE)

Software tools for Components:

I Source Code Editor I Compiler / Interpreter I Build Automation Tools I Debugger Facilitates software development

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 2 / 1 Python IDEs

IDLE (comes with Python, simple) Python IDE Stani’s Python IDE (powerful IDE for many programming languages, uses plugins: PyDev) NetBeans In this course, we introduce IDLE. You are free to use any other IDE, but don’t expect us to know everything about them! ,

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 3 / 1 Python Shell

Open IDLE → Python Shell (= interpreter, interactive mode) Type print(’Hello World!’) and hit enter.

Repeat prior commands: Alt+P (backwards) / Alt+N (forwards) On some Macs: Ctrl+P / Ctrl+N

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 4 / 1 Edit a Source Code File

Click File > New Window. This opens a new source code file. Enter some source code, e.g. print("Source Code says Hello!") Save the file as sourceCodeHello.py: File > Save Make sure to always add ".py" explicitly when saving files!

Syntax Highlighting: shows keywords / strings / ... in different colors.

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 5 / 1 Run a Source Code File

Click Run > Run Module (F5) Results of running your source code file will show up in the Python Shell.

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 6 / 1 Comments

1 # This isa comment. 2 # Each line starting with '#' isa comment. 3 print("Python ignores comments!") 4 print("Line with code...") # anda comment 5 """ 6 This 7 isa 8 multiline 9 comment. 10 """ 11 print("Python also ignores multiline comments.")

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 7 / 1 Read Text from Console

console_input.py

1 first = input("Input your first name:") 2 last = input("Input your last name:") 3 middle = input("Input your middle name if you 4 have one, or hit enter if you don't have one.") 5 print("Your full name is:", first, middle, last)

variable = input(prompt)

1 prints the text given in prompt on the console

2 waits for the user to enter some text string (terminated by ’enter’) 3 assigns the text string that the user has entered to variable

S. Thater and A. Friedrich ( Saarland University) Introduction to Python Programming Winter Semester 2011/2012 8 / 1