Objects
Lecture 9
Objects
Announcements for Today
Assignment 1
? We are starting grading
Assignment 2
? Posted Today
¡ì Will take most of the day
¡ì Grades 9am tomorrow
¡ì Written assignment
¡ì Do while revising A1
? Resubmit until correct
¡ì Read feedback in CMS
¡ì Reupload/request regrade
¡ì Relatively short (2-3 hrs)
? Due next Thursday
¡ì Submit as a PDF
? If you were very wrong¡
¡ì Scan or phone picture
¡ì You will get an e-mail
¡ì More 1-on-1s this week
9/23/21
¡ì US Letter format!
Objects
2
The Basic Python Types
? Type int:
? Type str:
¡ì Values: integers
¡ì Ops: +, ¨C, *, //, %, **
¡ì Values: string literals
? Double quotes: "abc"
? Single quotes: 'abc'
? Type float:
¡ì Ops: + (concatenation)
¡ì Values: real numbers
¡ì Ops: +, ¨C, *, /, **
? Type bool:
Are the the only
types that exist?
¡ì Values: True and False
¡ì Ops: not, and, or
9/23/21
Objects
3
Example: Points in 3D Space
def distance(x0,y0,z0,x1,y1,z1):
"""Returns distance between points (x0,y0,y1) and (x1,y1,z1)
Param x0: x-coord of 1st point
Precond: x0 is a float
? This is very unwieldy
¡ì Specification is too long
¡ì Calls needs many params
¡ì Typo bugs are very likely
Param y0: y-coord of 1st point
Precond: y0 is a float
Param z0: z-coord of 1st point
Precond: z0 is a float
¡.
"""
9/23/21
? Want to reduce params
¡ì Package points together
¡ì How can we do this?
Objects
4
Points as Their Own Type
def distance(p0,p1):
"""Returns distance between points p0 and p1
Param p0: The second point
Precond: p0 is a Point3
Param p1: The second point
Precond: p1 is a Point3"""
¡
9/23/21
This lecture will help you
make sense of this spec.
Objects
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
Related searches
- most mysterious objects ever discovered
- unexplained objects found on earth
- hidden objects free games no time limit
- 10 unexplained objects on earth
- 100 hidden objects free games
- free games hidden objects no time limits
- objects that start with i
- describing objects by their attributes
- objects that begin with i
- objects that go together
- free online hidden objects games no downloads
- hidden objects 247 games