Lecture 4

Lecture 4 - 1/30/11 ECE 364: Software Tools Laboratory...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1/30/11 1 ECE 364: Software Tools Laboratory Lecture 4 January 31, 2011 Lecturer: Michael Goldfarb 1 Lecture Summary § Introduction to Python § Common Data Types § Lists and Tuples § If Statement § For and While Loops § Reading from Standard Input 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1/30/11 2 What is Python? § Python is a flexible programming language § Procedural like C § Object-oriented like C++, Java and C# § Functional like Scheme § Python is a high-level language § Has a rich set of high-level data types and functions (standard library) § Runs on many platforms and operating systems § Windows, Linux/Unix, Mac OS and much more 3 What is Python? § Python is designed to be simplistic § Very simple and consistent syntax § Easy to read and write § Interactive like a shell 4
Background image of page 2
1/30/11 3 What is Python? § Python programs are translated into byte code § Byte code is executed by the Python virtual machine § Most Python implementations have an interactive mode § Some implementations provide more interactive features than others § Examples: IDLE, IPython 5 Syntax and Features § No braces { } § Indentation is used to indicate code blocks § Forces some level of readability § No semicolon at the end of a statement § Unless needed to separate multiple statements on one line § No $ preceding variable names 6
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1/30/11 4 Making a Python Script § Put #! on the first line #! /usr/bin/env python § This line invokes the env program to get the path to python 7 The Traceback § When Python crashes, you will see a message like Traceback (most recent call last): File "./tables.py", line 12, in <module> x_start = float(sys.argv[3]) ValueError: invalid literal for float(): c § Read it carefully, starting from the bottom and working upwards. § It is usually very accurate in pinpointing errors § It can save you a lot of time debugging 8
Background image of page 4
5 Interactive Mode § Interactive Python: § Useful for testing out things you're not sure about § Useful for prototyping algorithms § Invoke at the command line with: python ipython idle (graphical version) § Comes with a built in help function: >>> help(list) >>> import sys >>> help(sys) 9 Data Types and Dynamic Typing § Variables are not declared with types § The C language uses “ static typing § Semantics are defined by the set of functions and properties of the object § “If it looks like a duck and quacks like a duck,
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

Lecture 4 - 1/30/11 ECE 364: Software Tools Laboratory...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online