100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

CMU CS Academy Unit 2.1 Exercises and Solutions

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
11-11-2024
Written in
2024/2025

CMU CS Academy Unit 2.1 Exercises and Solutions 2.1.3 Two Hexagons def drawTwoHexagons(color): # Create two hexagons. Use the function parameter for the fill of the # top hexagon and the border of the bottom hexagon! ### Place Your Code Here ### RegularPolygon(200, 100, 100, 6, fill=color) RegularPolygon(200, 300, 100, 6, fill=None, border=color, borderWidth=8) ##### Place your code above this line, code below is for testing purposes ##### # test case: drawTwoHexagons('green') 2.1.3 Polygon Flower Rect(0, 0, 400, 400, fill='skyBlue') def drawFlower(color): # Change these shapes so they use the color parameter for the flower petals. ### Modify Your Code Here ### RegularPolygon(200, 300, 30, 4, fill='green') RegularPolygon(200, 340, 30, 4, fill='green') RegularPolygon(200, 380, 30, 4, fill='green') RegularPolygon(200, 200, 100, 4, fill=color) RegularPolygon(200, 200, 50, 4, fill='sienna') RegularPolygon(150, 150, 50, 4, fill=color) RegularPolygon(150, 250, 50, 4, fill=color) RegularPolygon(250, 150, 50, 4, fill=color) RegularPolygon(250, 250, 50, 4, fill=color) ##### Place your code above this line, code below is for testing purposes ##### # test case: drawFlower('gold') Previous Play Next Rewind 10 seconds Move forward 10 seconds Unmute 0:05 / 0:15 Full screen Brainpower Read More 2.1.3 3D Labels Rect(0, 0, 400, 400, fill='aliceBlue') def draw3DLabel(text): # Draw two labels, one centered slightly to the right of the other. ### Place Your Code Here ### Label(text, 205, 200, size=65, fill='darkGreen', font='arial', bold=True) Label(text, 200, 200, size=65, fill='limeGreen', font='arial', bold=True) ##### Place your code above this line, code below is for testing purposes ##### # test case: draw3DLabel('Hello World') 2.1.3 Cooking an Egg Rect(0, 0, 400, 400, fill='goldenrod') # pan Line(105, 305, 0, 400, fill='dimGrey', lineWidth=40) Circle(200, 200, 145, fill=rgb(60, 60, 60), border='darkGrey', borderWidth=10) Circle(200, 200, 135, fill=None, border=gradient('black', 'black', 'black', 'dimGrey'), borderWidth=20) def drawEgg(opacity): # Draw the egg, using the opacity provided to the function. ### Place Your Code Here ### Oval(230, 220, 100, 120, fill='white', opacity=opacity) Circle(220, 220, 20, fill='gold', opacity=opacity) ##### Place your code above this line, code below is for testing purposes ##### # test case: drawEgg(100) 2.1.3 Bunny With a Spot def drawBunny(bunnyColor): Rect(0, 0, 400, 400, fill=gradient('dodgerBlue', 'deepSkyBlue')) # Change the ears below to use the parameter of the function as the fill. ### Fix Your Code Here ### Oval(155, 110, 60, 170, fill=bunnyColor) Oval(245, 110, 60, 170, fill=bunnyColor) Oval(155, 115, 40, 140, fill=gradient('seashell', 'wheat', start='bottom')) Oval(245, 115, 40, 140, fill=gradient('seashell', 'wheat', start='bottom')) # head Oval(200, 230, 200, 160, fill='white') Circle(150, 300, 80, fill='white') Circle(250, 300, 80, fill='white') # nose Polygon(180, 310, 220, 310, 200, 350) # Draw the spot around the eye. ### Place Your Code Here ### # eyes Oval(250, 270, 60, 100, fill=bunnyColor) Oval(150, 275, 30, 50) Oval(150, 270, 10, 20, fill='white') Oval(250, 275, 30, 50) Oval(250, 270, 10, 20, fill='white') ##### Place your code above this line, code below is for testing purposes ##### # test case: drawBunny('pink') 2.1.5 Inflating Balloon Rect(0, 0, 400, 400, fill='skyBlue') def drawBalloon(inflatedAmount, lightColor, darkColor): # Update these shapes to use the parameters. ### Fix Your Code Here ### RegularPolygon(200, 370, 20, 3, fill=darkColor) Oval(200, 185, inflatedAmount, 340, fill=gradient(lightColor, darkColor, start='right-top')) ##### Place your code above this line, code below is for testing purposes ##### # test case: drawBalloon(300, 'lightSalmon', 'crimson') 2.1.5 Three Stripe Flag def threeStripeFlag(country, color1, color2, color3): # Fix the label so it uses the function parameter: country. ### Fix Your Code Here ### Label(country, 200, 60, size=40, bold=True) # Draw the rectangles and use the correct function parameters for each one! ### Place Your Code Here ### Rect(50, 100, 100, 200, fill=color1) Rect(150, 100, 100, 200, fill=color2) Rect(250, 100, 100, 200, fill=color3) ##### Place your code above this line, code below is for testing purposes ##### # test case: threeStripeFlag('Belgium', 'black', 'gold', 'red') 2.1.5 Splash # water Rect(0, 0, 400, 400, fill=gradient('royalBlue', 'dodgerBlue', start='top')) # lilypads Circle(70, 50, 40, fill=gradient('limeGreen', 'forestGreen')) Circle(350, 175, 30, fill=gradient('limeGreen', 'forestGreen')) Circle(140, 355, 35, fill=gradient('limeGreen', 'forestGreen')) Star(105, 30, 35, 3, fill='royalBlue') Star(140, 390, 30, 3, fill='dodgerBlue') # flower Circle(70, 40, 8, fill=gradient('darkOrchid', 'lavender', start='left-bottom')) Circle(50, 40, 8, fill=gradient('darkOrchid', 'lavender', start='right-bottom')) Circle(70, 60, 8, fill=gradient('darkOrchid', 'lavender', start='left-top')) Circle(50, 60, 8, fill=gradient('darkOrchid', 'lavender', start='right-top')) Circle(60, 38, 8, fill=gradient('darkOrchid', 'lavender', start='bottom')) Circle(73, 50, 8, fill=gradient('darkOrchid', 'lavender', start='left')) Circle(60, 62, 8, fill=gradient('darkOrchid', 'lavender', start='top')) Circle(47, 50, 8, fill=gradient('darkOrchid', 'lavender', start='right')) Circle(60, 50, 8, fill='gold') def drawSplash(centerX, centerY): # Draw a splash using four circles with different radii and opacities. ### Place Your Code Here ### Circle(centerX, centerY, 80, fill='deepSkyBlue', opacity=30) Circle(centerX, centerY, 60, fill='deepSkyBlue', opacity=50) Circle(centerX, centerY, 40, fill='deepSkyBlue', opacity=70) Circle(centerX, centerY, 20, fill='deepSkyBlue', opacity=90) ##### Place your code above this line, code below is for testing purposes ##### # test case: drawSplash(200, 200) 2.1.5 Airport Sign # sign Rect(0, 0, 400, 400, fill='whiteSmoke') Rect(20, 50, 360, 100, fill='gold', border='black') Rect(20, 150, 360, 220, fill=rgb(40, 40, 40)) Label('Departures', 200, 87, size=36) Label('TIME', 50, 135, size=14) Label('DESTINATION', 200, 135, size=14) Label('GATE', 340, 135, size=14) Rect(33, 65, 45, 45, fill='white', border='black') Polygon(44, 80, 50, 89, 43, 91, 37, 85, 41, 94, 73, 86, 75, 84, 70, 83, 57, 85) # departed flights Label('02:00', 50, 180, fill='dimGray', size=20, bold=True) Label('Chicago', 200, 180, fill='dimGray', size=20, bold=True) Label('C12', 355, 180, fill='dimGray', size=20, bold=True) Label('03:00', 50, 230, fill='dimGray', size=20, bold=True) Label('Toronto', 200, 230, fill='dimGray', size=20, bold=True) Label('B97', 355, 230, fill='dimGray', size=20, bold=True) Label('03:30', 50, 280, fill='dimGray', size=20, bold=True) Label('Reykjavik', 200, 280, fill='dimGray', size=20, bold=True) Label('A82', 355, 280, fill='dimGray', size=20, bold=True) def updateDepartingFlights(time, destination, gate): # Update the flight information below. ### Fix Your Code Here ### Label(time, 50, 330, fill='whiteSmoke', size=20, bold=True) Label(destination, 200, 330, fill='whiteSmoke', size=20, bold=True) Label(gate, 355, 330, fill='whiteSmoke', size=20, bold=True) ##### Place your code above this line, code below is for testing purposes ##### # test case: updateDepartingFlights('04:00', 'Madrid', 'D82')

Show more Read less
Institution
SPLA
Course
SPLA









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
SPLA
Course
SPLA

Document information

Uploaded on
November 11, 2024
Number of pages
5
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

CMU CS Academy Unit 2.1 Exercises
and Solutions
2.1.3 Two Hexagons - answer def drawTwoHexagons(color):
# Create two hexagons. Use the function parameter for the fill of the
# top hexagon and the border of the bottom hexagon!
### Place Your Code Here ###
RegularPolygon(200, 100, 100, 6, fill=color)
RegularPolygon(200, 300, 100, 6, fill=None, border=color, borderWidth=8)
##### Place your code above this line, code below is for testing purposes #####
# test case:
drawTwoHexagons('green')

2.1.3 Polygon Flower - answer Rect(0, 0, 400, 400, fill='skyBlue')
def drawFlower(color):
# Change these shapes so they use the color parameter for the flower petals.
### Modify Your Code Here ###
RegularPolygon(200, 300, 30, 4, fill='green')
RegularPolygon(200, 340, 30, 4, fill='green')
RegularPolygon(200, 380, 30, 4, fill='green')
RegularPolygon(200, 200, 100, 4, fill=color)
RegularPolygon(200, 200, 50, 4, fill='sienna')
RegularPolygon(150, 150, 50, 4, fill=color)
RegularPolygon(150, 250, 50, 4, fill=color)
RegularPolygon(250, 150, 50, 4, fill=color)
RegularPolygon(250, 250, 50, 4, fill=color)
##### Place your code above this line, code below is for testing purposes #####
# test case:
drawFlower('gold')

2.1.3 3D Labels - answer Rect(0, 0, 400, 400, fill='aliceBlue')
def draw3DLabel(text):
# Draw two labels, one centered slightly to the right of the other.
### Place Your Code Here ###
Label(text, 205, 200, size=65, fill='darkGreen', font='arial', bold=True)
Label(text, 200, 200, size=65, fill='limeGreen', font='arial', bold=True)
##### Place your code above this line, code below is for testing purposes #####
# test case:
draw3DLabel('Hello World')

2.1.3 Cooking an Egg - answer Rect(0, 0, 400, 400, fill='goldenrod')
# pan
Line(105, 305, 0, 400, fill='dimGrey', lineWidth=40)

, Circle(200, 200, 145, fill=rgb(60, 60, 60), border='darkGrey', borderWidth=10)
Circle(200, 200, 135, fill=None,
border=gradient('black', 'black', 'black', 'dimGrey'), borderWidth=20)
def drawEgg(opacity):
# Draw the egg, using the opacity provided to the function.
### Place Your Code Here ###
Oval(230, 220, 100, 120, fill='white', opacity=opacity)
Circle(220, 220, 20, fill='gold', opacity=opacity)
##### Place your code above this line, code below is for testing purposes #####
# test case:
drawEgg(100)

2.1.3 Bunny With a Spot - answer def drawBunny(bunnyColor):
Rect(0, 0, 400, 400, fill=gradient('dodgerBlue', 'deepSkyBlue'))
# Change the ears below to use the parameter of the function as the fill.
### Fix Your Code Here ###
Oval(155, 110, 60, 170, fill=bunnyColor)
Oval(245, 110, 60, 170, fill=bunnyColor)
Oval(155, 115, 40, 140, fill=gradient('seashell', 'wheat', start='bottom'))
Oval(245, 115, 40, 140, fill=gradient('seashell', 'wheat', start='bottom'))
# head
Oval(200, 230, 200, 160, fill='white')
Circle(150, 300, 80, fill='white')
Circle(250, 300, 80, fill='white')
# nose
Polygon(180, 310, 220, 310, 200, 350)
# Draw the spot around the eye.
### Place Your Code Here ###
# eyes
Oval(250, 270, 60, 100, fill=bunnyColor)
Oval(150, 275, 30, 50)
Oval(150, 270, 10, 20, fill='white')
Oval(250, 275, 30, 50)
Oval(250, 270, 10, 20, fill='white')
##### Place your code above this line, code below is for testing purposes #####
# test case:
drawBunny('pink')

2.1.5 Inflating Balloon - answer Rect(0, 0, 400, 400, fill='skyBlue')
def drawBalloon(inflatedAmount, lightColor, darkColor):
# Update these shapes to use the parameters.
### Fix Your Code Here ###
RegularPolygon(200, 370, 20, 3, fill=darkColor)
Oval(200, 185, inflatedAmount, 340,
fill=gradient(lightColor, darkColor, start='right-top'))
##### Place your code above this line, code below is for testing purposes #####

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Pogba119 Harvard University
View profile
Follow You need to be logged in order to follow users or courses
Sold
48
Member since
1 year
Number of followers
2
Documents
4863
Last sold
3 weeks ago
NURSING TEST

BEST EDUCATIONAL RESOURCES FOR STUDENTS

3.9

9 reviews

5
4
4
2
3
2
2
0
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions