[Tutor] Scheme
Alan Gauld
alan.gauld at btinternet.com
Fri Aug 31 09:55:04 CEST 2012
On 31/08/12 00:32, Ashley Fowler wrote:
> This is a problem using the Scheme programming...Can anybody help me
> with this problem?
>
> 2. Write a procedure (sphere r) that takes the radius of a sphere
> as the value of its input parameter and returns the volume of that
> sphere given by the formula: (4/3)π(r^3). Use (require scheme/math)
> or (require racket/math) to load the math library containing the
> "pi" constant.
from math import pi
def sphere(r):
return (4.0/3) * math.pi *(r**3)
> Be sure to use "cube" from problem (1) to find the cube of r (r^3).
Sorry I don't have access to problem 1 but luckily in Python I don't
need it!
Now just translate that into Scheme :-)
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list