Functions Mixed-Up Code QuestionsΒΆ
Create a function called exp
that takes in two parameters, num1
and num2
, and returns num1
raised to the
power of num2
. For example, exp(2,3)
should return 8
.
Write a function called exp
that takes in two parameters, num1
and num2
, and returns num1
raised to the
power of num2
. For example, exp(2,3)
should return 8
.
Create a function called poly_perimeter
that takes in two parameters, len_side
and num_sides
, and
returns the perimeter of the polygon. The perimeter of a polygon is the length of each side times the number of sides. For example, poly_perimeter(4,5)
should return 20
.
Write a function called poly_perimeter
that takes in two parameters, len_side
and num_sides
, and
returns the perimeter of the polygon. The perimeter of a polygon is the length of each side times the number of sides. For example, poly_perimeter(4,5)
should return 20
.
Create a function called sphere_volume
that takes in one parameter, radius
, and
returns the volume of a sphere with the given radius
. The volume of a sphere is 4 / 3 times PI (in which 3.14 should be used) times the radius
cubed.
For example, sphere_volume(3)
should return 113.04
.
Write a function called sphere_volume
that takes in one parameter, radius
, and
returns the volume of a sphere with the given radius
. The volume of a sphere is 4 / 3 times PI (in which 3.14 should be used) times the radius
cubed.
For example, sphere_volume(3)
should return 113.04
.
Create a function called circle_circumference
that takes in one parameter, radius
, and returns the
circumference of a circle with the given radius
. The circumference of a circle is 2 times PI (in which 3.14 should be used) times the radius
. For example,
circle_circumference(3)
should return 18.84
.
Write a function called circle_circumference
that takes in one parameter, radius
, and returns the
circumference of a circle with the given radius
. The circumference of a circle is 2 times PI (in which 3.14 should be used) times the radius
. For example,
circle_circumference(3)
should return 18.84
.
Create a function called slope
that takes in four parameters, x1
, x2
, y1
, and y2
, and
returns the slope of a line formed by the two points. The slope is y2
minus y1
divided by x2
minus x1
.
For example, slope(4, 3, 7, 8)
should return -1
.
Write a function called slope
that takes in four parameters, x1
, x2
, y1
, and y2
, and
returns the slope of a line formed by the two points. The slope is y2
minus y1
divided by x2
minus x1
.
For example, slope(4, 3, 7, 8)
should return -1
.
Create a function called get_hypotenuse
that takes in two parameters, angle
and opposite_side
, and
returns the hypotenuse of a right triangle. angle
contains the angle facing the opposite side in degrees.
The sine function takes in a value in radians. The sine of an angle is equal to the opposite side over the hypotenuse.
Write a function called get_hypotenuse
that takes in two parameters, angle
and opposite_side
, and
returns the hypotenuse of a right triangle. angle
contains the angle facing the opposite side in degrees.
The sine function takes in a value in radians. The sine of an angle is equal to the opposite side over the hypotenuse.
Create a function called convert_to_miles
that takes in feet
as a parameter and
returns the value in miles. feet
contains the length of an object in feet. 1 mile is equal to 5280 feet.
Write a function called convert_to_miles
that takes in feet
as a parameter and
returns the value in miles. feet
contains the length of an object in feet. 1 mile is equal to 5280 feet.
Create a function called even_odd
that takes in integer
as a parameter and
returns 1 if the integer is even, 2 if the integer is odd, or 3 if neither is true.
Write a function called even_odd
that takes in integer
as a parameter and
returns 1 if the integer is even, 2 if the integer is odd, or 3 if neither is true.
Create a function called larger_string
that takes in two parameters, str1
and str2
, and
returns the string that has the larger length. If the lengths are equal, return str1
.
Write a function called larger_string
that takes in two parameters, str1
and str2
, and
returns the string that has the larger length. If the lengths are equal, return str1
.
Create a function called find_distance
that takes in four parameters, x1
, y1
, x2
, and y2
, and
returns the distance between these two points.
Write a function called find_distance
that takes in four parameters, x1
, y1
, x2
, and y2
, and
returns the distance between these two points.