100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CMU CS Academy Unit 2.1 Exercises and Solutions $13.49   Add to cart

Exam (elaborations)

CMU CS Academy Unit 2.1 Exercises and Solutions

 3 views  0 purchase
  • Course
  • SPLA
  • Institution
  • SPLA

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) ...

[Show more]

Preview 2 out of 5  pages

  • November 11, 2024
  • 5
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • SPLA
  • SPLA
avatar-seller
Pogba119
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 #####

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Pogba119. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75632 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.49
  • (0)
  Add to cart