Chapter 1: Python Basics
Download
Report
Transcript Chapter 1: Python Basics
Chapter 1: Python Basics
CSCI-UA 0002 – Introduction to Computer
Programming
Mr. Joel Kemp
Agenda
• What is Python?
• How do we get it?
• How do we execute our programs?
This material can be found in Chapter 3 of the Visual Quickstart Guide
What is Python?
• A programming language that emphasizes
readable code!
– Combines power with clear syntax.
– Interpreted not compiled!
• Why are we using it?
– Very beginner friendly!
– Beginners shouldn’t be burdened with syntax.
• Semicolons, braces, pointers, datatype declarations.
• Increases programmer productivity.
From Design to Interpretation
Installing Python
• Visit python.org/download
– For Windows Users: Python
3.2 Windows x86 MSI installer
– For Mac Users: Python 3.2 64bit/32-bit Installer
• Run the downloaded installer
and complete the installation
process.
Before We Start
• Python code is placed in a regular text file that must end with
the .py extension.
– Can be written in any plain text editor:
• Notepad, Notepad++
• TextEdit, TextWrangler
(Windows)
(Mac OSX)
– Avoid using Wordpad and Microsoft Word!
• Integrated Development Environment (IDE)
– Definition: a large computer program that provides tools for
increasing productivity in software development.
– Tools:
•
•
•
•
Intellisense/Auto-Completion
Real-time error-checking
Debugging
Compiler and/or Interpreter
– We’ll be using the IDLE IDE!
IDLE IDE
• Included with the Python Installation!
• Written in Python!
• Allows us to bypass running python files from the
command line!
Running a Python File (Command Line)
1. Open the command prompt or terminal.
2. Navigate to the location of the python file:
– Use the cd command to access folders.
– Use the cd command with two periods (cd ..) to
move backward in the filesystem.
3. To run/interpret the python file:
– Type python filename.py (where filename is
the file you’re trying to run)
Running a Python File (IDLE)
1. Create a new file or open an existing python file.
2. Click on the Run Module button in the Run
menu!