forked from CSSE120StartingCode/ObjectsFunctionsAndMethods
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathm3_practice_fixing_errors.py
More file actions
75 lines (60 loc) · 2.3 KB
/
m3_practice_fixing_errors.py
File metadata and controls
75 lines (60 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""
This module lets you practice correcting SYNTAX (notation) errors.
Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder,
their colleagues and Benjamin Feaster.
""" # DONE: 1. PUT YOUR NAME IN THE ABOVE LINE.
########################################################################
# DONE: 2.
# Locate the syntax (notation) errors in this file
# by looking for red underlines.
#
# For each error, try to make sense of its message.
# -- Hover or expand as needed -- make sure you see the message!
#
# Then fix the errors, one by one.
# -- Fixing one error may bring up additional errors
# (after a few seconds or when you run or save the module).
# -- Each time, fix the ERROR that is currently nearest the TOP of the module.
# -- Often the SOURCE of the error can be on the line just BEFORE
# the line with a red underline.
# -- New errors may appear when you RUN the module.
#
# Finish by RUNNING the corrected program and making sure that it RUNS CORRECTLY.
# That is, make sure that (per the doc-strings) the program
# prints some calculated values and makes a Turtle do some things.
#
# When complete Commit and Push your work (as always).
#
########################################################################
import rosegraphics as rg
import math
def main():
""" Calls the other functions in this module to demo them. """
print_math()
turtle_fun()
def print_math():
""" Prints some calculated values. """
x = math.cos(math.pi)
print('The cosine of PI is', x)
y = math.sin(math.pi)
print('The sine of PI is', y)
def turtle_fun():
"""
Constructs a TurtleWindow,
constructs a classic SimpleTurtle and asks it to do some things,
and waits for the user to click anywhere in the window to close it.
"""
window = rg.TurtleWindow()
alan = rg.SimpleTurtle()
alan.pen = rg.Pen('blue', 30)
alan.paint_bucket = rg.PaintBucket('yellow')
alan.backward(3 * (47 + 16))
alan.begin_fill()
alan.draw_circle(25)
alan.end_fill()
alan.forward(200)
window.close_on_mouse_click()
# ----------------------------------------------------------------------
# Calls main to start the ball rolling.
# ----------------------------------------------------------------------
main()