Lecture 4 - ECE 364 Software Tools Laboratory Lecture 4...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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
Image of page 4
1/30/11 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 §੿
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern