Basic Python Programs, Software Engineering Tools Rose-Hulman - - PowerPoint PPT Presentation

basic python programs software engineering tools
SMART_READER_LITE
LIVE PREVIEW

Basic Python Programs, Software Engineering Tools Rose-Hulman - - PowerPoint PPT Presentation

Basic Python Programs, Software Engineering Tools Rose-Hulman Institute of Technology Computer Science and Software Engineering Announcements Homework timing: Reading quizzes due Other parts of assignments due Day assigned (next class


slide-1
SLIDE 1

Basic Python Programs, Software Engineering Tools

Rose-Hulman Institute of Technology Computer Science and Software Engineering

slide-2
SLIDE 2

Announcements

  • Homework timing:

Day assigned Reading quizzes due (next class day – 8AM) Other parts of assignments due 8 AM

Monday Tuesday Wednesday Tuesday Thursday Thursday Thursday Monday Monday

Q1

slide-3
SLIDE 3

Sample Scenes from HW 1

Who wants to share?

slide-4
SLIDE 4

Outline

  • Goals for today:

– Get started with Eclipse and Subversion – Learn and practice writing small programs

  • Functions
  • The main function
  • The input-compute-output pattern
  • Examples: chaos, temperature, kph
slide-5
SLIDE 5

Integrated Development Environments

  • What do they do?
  • Why use one?
  • Our IDE − Eclipse

Details on next slides

slide-6
SLIDE 6

IDEs − − − − What do they do?

Let us compile, run, and debug Show an

  • utline of our

module (file) Help us enter and edit code Show outline of entire project

Display program

  • utput
slide-7
SLIDE 7

IDEs − − − − Why use one?

  • Harness the power of the computer to

make us more productive!

slide-8
SLIDE 8

IDEs − − − − Why Eclipse?

  • Powerful
  • Easy to use
  • Free and open-source
  • An IDE for any language, not just Python
slide-9
SLIDE 9

Basic concepts in Eclipse

  • Workspace − where your projects are stored on your

computer

  • Project − a collection of files, organized in folders, that

includes:

– Source code – Compiled code – Design documents – Documentation – Tests – And more…

slide-10
SLIDE 10

Fixing Eclipse First

  • Link from home page

http://www.rose- hulman.edu/class/csse/resources/Installatio nInstructions/2011- 2012/EclipseWorkaround-2011-2012.html

slide-11
SLIDE 11

Setting up Eclipse

  • Just need to do this the first time!
  • Follow along with me

– We will:

  • Open Eclipse
  • Set the workspace
  • Switch to the PyDev120 perspective

– If your setup is different, see

  • http://www.rose-hulman.edu/class/csse/resources/Eclipse/installation.htm
slide-12
SLIDE 12

Follow Along…

  • 1. File New Pydev Project
  • 2. File New Pydev Module
  • 3. Type

print("hello world")

  • 4. Run the program
  • 5. Type a few more print statements, including one

that is wrong.

– See where the error message appears and how clicking

  • n it brings you to the offending line.

Help us enter and edit code

slide-13
SLIDE 13

Views, Editors, PyDev Perspectives

Tabbed views of source code Package explorer view Tabbed views of results Editor view Outline view Perspective switcher

slide-14
SLIDE 14

Eclipse in a Nutshell

  • Workspace − where your projects are stored
  • n your computer
  • Project − a collection of files, organized in

folders

  • Perspective − a set of views and editors
  • View − an area of a window showing focused

information (code, outline, results, etc.)

slide-15
SLIDE 15

Software Engineering Tools

  • IDEs, like Eclipse and IDLE
  • Version Control Systems, like Subversion
  • Testing frameworks, like JUnit
  • Diagramming applications, like UMLet, Violet

and Visio

  • Modeling languages, like Alloy, Z, and JML
  • Task management trackers like TRAC
slide-16
SLIDE 16

Version Control Systems

Store “snapshots” of all the changes to a project over time

slide-17
SLIDE 17

Version Control Systems

  • Benefits for individual work:

– Logging and Backups – Act as a “global undo” to whatever version you want to go back to – Maintain a log of the changes made – Can simplify debugging

slide-18
SLIDE 18

Version Control Systems

  • Benefits for group work:

– Multiple users can share work on a project – Record who made what changes to a project – Provide help in resolving conflicts between what the multiple users do – Maintain multiple different versions of a project simultaneously

slide-19
SLIDE 19

Version Control Systems

  • Benefits for CSSE 120 programming work:

– Three-click turn in for programming projects – Get back comments from the grader right in the code – No need for ANGEL drop boxes

slide-20
SLIDE 20

Our Version Control System

  • Subversion, sometimes called SVN
  • A free, open-source application
  • Lots of tool support available

– Works on all major computing platforms – TortoiseSVN for version control in Windows Explorer – Subclipse for version control inside Eclipse

Q2a

slide-21
SLIDE 21

Version Control Terms

Subversion Server

Alice's Computer Bob's Computer Instructor's Computer

Alice's Repository Bob's Repository

Repository: the copy of your data on the server, includes all past versions Working copy: the current version of the files, on your computer

Working Copy Working Copy Working Copy Working Copy

Q2b

slide-22
SLIDE 22

Version Control Steps—Check Out

Subversion Server

Alice's Computer Bob's Computer Instructor's Computer

Alice's Repository Bob's Repository

… …

Working Copy Working Copy Working Copy Working Copy

Check out: grab a new working copy from the repository Q3a

slide-23
SLIDE 23

Version Control Steps—Edit

Subversion Server

Alice's Computer Bob's Computer Instructor's Computer

Alice's Repository

Bob's

Repository

Working Copy Working Copy Working Copy Working Copy

Edit: make independent changes to a working copy

slide-24
SLIDE 24

Version Control Steps—Commit

Subversion Server

Alice's Computer Bob's Computer Instructor's Computer

Alice's Repository Bob's Repository

Working Copy Working Copy Working Copy Working Copy

Commit: send a snapshot of changes back to the repository

Q3b

slide-25
SLIDE 25

Version Control Steps—Update

Subversion Server

Alice's Computer Bob's Computer Instructor's Computer

Alice's Repository Bob's Repository

Working Copy Working Copy Working Copy Working Copy

Update: make working copy reflect changes from repository

Q3c

slide-26
SLIDE 26

The Version Control Cycle

Check Out Edit Update Commit Update

Update and Commit often!

slide-27
SLIDE 27

Check out today’s project

  • Follow along
  • You’ll need:

– Subversion URL from Homework 2 – SVN password

slide-28
SLIDE 28

Functions

  • Examine the hello.py module in your

Eclipse project.

  • Functions

– Named sequences of statements – We can invoke them—make them run – They can take parameters—changeable parts

slide-29
SLIDE 29

Parts of a Function Definition

>>> def hello(): print("Hello") print("I'd like to complain about this parrot")

Defining a function called “hello” Indenting tells interpreter that these lines are part

  • f the hello function

Entering a blank line tells interpreter that we’re done defining the hello function

slide-30
SLIDE 30

Defining vs. Invoking

  • Defining a function says what it should do
  • Invoking (calling) a function makes that

happen

– Parentheses tell the interpreter to invoke the function – Later we’ll define functions with parameters

>>> hello() Hello I'd like to complain about this parrot Q4

slide-31
SLIDE 31

Identifiers: Names in Programs

  • Uses of identifiers so far…

– Modules – Functions – Variables

  • Rules for identifiers in Python

– Start with a letter or _ (the “underscore character”) – Followed by any sequence of letters, numbers, or _

  • Case matters! spam ≠ Spam ≠ sPam ≠ SPAM
  • Choose descriptive names!

Q5a

slide-32
SLIDE 32

Reserved Words

  • Built-in names, can’t be used as identifiers
  • Python reserved words:

and del for is raise assert elif from lambda return break else global not try class except if

  • r

while continue exec import pass with def finally in print yield

Q5b

slide-33
SLIDE 33

Don’t redefine function names!

  • Examples that trip me up:

– len – used to find the length of a list – max – min

slide-34
SLIDE 34

Expressions

  • Fragments of code that produce or calculate new

data values

  • Examples

– Literals: indicate a specific value: 2, 3.5, "hello" – Identifiers: evaluate to their assigned value: x, width – Compound expressions contain other expressions:

  • E.g., 3 + 4 * 2, x < 5
  • Can use parentheses to group: (3 + 4) * 2

Q6,7

slide-35
SLIDE 35

Recall…

  • Programming languages have precise rules

for:

– Syntax (form) – Semantics (meaning)

  • Computer scientists use meta-languages to

describe these rules

  • Example…
slide-36
SLIDE 36

Output Statements

  • Syntax:

– print() – print(<expr>) – print(<expr>, …) – print(<expr>, …, end=<str>)

  • Are these allowed?

– print("The answer is:", 7 * 3 * 2) – print(3, 5, 7, end="")

  • Semantics?

A “slot” to be filled with any expression Repeat indefinitely as many times as desired, zero or more

Q8

slide-37
SLIDE 37

The input-compute-output pattern

  • Examine the chaos.py module in your

Eclipse project.

  • Do the TODOs in it.

– I’ll demo some of them with you.

  • Commit your code:

– Right-click project Team Commit…

Q9-13

slide-38
SLIDE 38

The Software Development Process

Analyze the Problem Determine Specifications Create a Design Implement the Design Test/Debug the Program Maintain the Program

Q14

slide-39
SLIDE 39

More input-compute-output practice

  • Examine the temperature.py module in

your Eclipse project

  • Do the TODOs in it
slide-40
SLIDE 40

Homework

  • Hand in quiz
  • Begin homework

– Find it from the Schedule page – Reading and ANGEL quiz due Tuesday 8 AM – Rest (programming part) due Wednesday 8 AM

Q15