Lecture 6

[Pages:38]Lecture 6

Specifications & Testing

Announcements For This Lecture

Last Call

Assignment 1

? Acad. Integrity Quiz ? Take it by tomorrow ? Also remember survey

? Posted on web page

? Due Wed, Sep. 22nd ? Today's lab will help ? Revise until correct

? Can work in pairs

? We will pair if needed ? Submit request TONIGHT ? One submission per pair

9/14/21

Specifications & Testing

2

One-on-One Sessions

? Started Monday: 1/2-hour one-on-one sessions

? To help prepare you for the assignment ? Primarily for students with little experience

? There are still some spots available

? Sign up for a slot in CMS

? Will keep running after September 22nd

? Will open additional slots after the due date ? Will help students revise Assignment 1

9/14/21

Specifications & Testing

3

Recall: The Python API

Function name

Possible arguments

Module

9/14/21

What the function evaluates to

? This is a specification

? Enough info to call function ? But not how to implement

? Write them as docstrings

Specifications & Testing

4

Anatomy of a Specification

def greet(n):

One line description, followed by blank line

"""Prints a greeting to the name n

Greeting has format 'Hello !' Followed by conversation starter.

Parameter n: person to greet Precondition: n is a string""" print('Hello '+n+'!') print('How are you?')

9/14/21

Specifications & Testing

5

Anatomy of a Specification

def greet(n):

One line description, followed by blank line

"""Prints a greeting to the name n

Greeting has format 'Hello !' Followed by conversation starter.

More detail about the function. It may be many paragraphs.

Parameter n: person to greet Precondition: n is a string""" print('Hello '+n+'!') print('How are you?')

9/14/21

Specifications & Testing

6

Anatomy of a Specification

def greet(n):

One line description, followed by blank line

"""Prints a greeting to the name n

Greeting has format 'Hello !' Followed by conversation starter.

More detail about the function. It may be many paragraphs.

Parameter n: person to greet Precondition: n is a string""" print('Hello '+n+'!') print('How are you?')

Parameter description

9/14/21

Specifications & Testing

7

Anatomy of a Specification

def greet(n):

One line description, followed by blank line

"""Prints a greeting to the name n

Greeting has format 'Hello !' Followed by conversation starter.

More detail about the function. It may be many paragraphs.

Parameter n: person to greet Precondition: n is a string""" print('Hello '+n+'!') print('How are you?')

Parameter description

Precondition specifies assumptions we make about the arguments

9/14/21

Specifications & Testing

8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download