Difference between revisions of "CSC111 Final Exam 2018"
Line 183: | Line 183: | ||
* Your JES program should only ask the user for a file name, nothing else. | * Your JES program should only ask the user for a file name, nothing else. | ||
* If you need help capturing the final image, please visit [http://www.take-a-screenshot.org/ this page]. | * If you need help capturing the final image, please visit [http://www.take-a-screenshot.org/ this page]. | ||
+ | * You may find these functions useful... | ||
+ | ::<source lang="python"> | ||
+ | # distanceDemo.py | ||
+ | # D. Thiebaut | ||
+ | |||
+ | from math import * | ||
+ | from graphics import * | ||
+ | |||
+ | def distance( x1, y1, x2, y2 ): | ||
+ | return sqrt( (x1-x2)*(x1-x2) + | ||
+ | (y1-y2)*(y1-y2) ) | ||
+ | |||
+ | def distanceP( p1, p2 ): | ||
+ | x1, y1 = p1.getX(), p1.getY() | ||
+ | x2, y2 = p2.getX(), p2.getY() | ||
+ | return distance( x1, y1, x2, y2 ) | ||
+ | |||
+ | def main(): | ||
+ | point1 = Point( 3, 5 ) | ||
+ | point2 = Point( 7, 8 ) | ||
+ | d = distanceP( point1, point2 ) | ||
+ | print( "distance =", d ) | ||
+ | |||
+ | main() | ||
+ | </source> | ||
<br /> | <br /> | ||
==Submission== | ==Submission== |