Question: How can I code this in Python with only if-statements? (Only allowed to use the built-in functions int(), float(), and str().) def sphere_quadrant(x,y,z) Description: Given
How can I code this in Python with only if-statements? (Only allowed to use the built-in functions int(), float(), and str().)
def sphere_quadrant(x,y,z)
Description: Given the three coordinates of a 3D point decide what quadrant of a sphere this point lies in. The sphere (depicted in Figure 1) is centered on the origin (0,0,0) and has a radius of 1.
Parameters: x (float), y (float), z (float) are the coordinates of the 3D point. All three parameters are guaranteed to have non zero values.
Return value: The color of the quadrant the 3D point lies in as a string containing one of the following values: blue, green, brown, magenta. Moreover, if the 3D point lies beneath the surface (i.e the XY plane you see in the figure), prepend the above string with the string lower. Last, if the 3D point lies anywhere outside the sphere, return False (Hint: use the extension of the pythagorean theorem to three-dimensional space to calculate the distance from the origin).

Examples:
sphere_quadrant(1,1,1) False
sphere_quadrant(0.5,0.5,0.5) "green"
sphere_quadrant(-0.5,-0.5,-0.5) "lower blue"
-00 Y axis +00 X axis > +00 Z axis -00 Figure 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
