Lec3FuncsForLoops

Lec3FuncsForLoops - We want to calculate the volume of a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
We want to calculate the volume of a cylinder. The cylinder has a radius of 3cm and a height of 7 cm. Create variables and set them to values to calculate the volume. Save any intermediate results also in a variable. Properly name your variables. area = pi * r^2 pi = 3.1415 height = 7 radius = 3 area = (pi * (radius ** 2)) volume = area * height 1) Tell python where your cTurtle module is located import sys; sys.path.append(“/Users/Shared/cs8”) 2) As python to import cTurtle import cTurtle walle = cTurtle.Turtle() # this calls the constructor for the turtle Problem from last time: Draw the outline of a star using the cTurtle To open a window for typing in your code to run all at once, File->Open Window File->Save As (give it a name.py) Run->Run Module # this runs all the code in sequence We want to create a function that executes all of the instructions necessary to draw the Star. This is called an abstraction. An abstraction removes the details for some task or operation. There are three levels to making an abstraction
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Lec3FuncsForLoops - We want to calculate the volume of a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online