Functions and Conditionals Mixed-Up Code Questions¶
Create a function called get_grade
that takes in a parameter percentage
and returns a string variable called letter_grade
.
If the percentage
is greater than 100, return "You can't get over 100."
. Otherwise, it should return 'A'
if the score is greater than or equal to 90,
'B'
if greater than or equal to 80, 'C'
if greater than or equal to 70, 'D'
if greater than or equal to 60, and otherwise 'E'
.
For example, get_grade(90)
should return 'A'
.
Write a function called get_grade
that takes in a parameter percentage
and returns a string variable called letter_grade
.
If the percentage
is greater than 100, return "You can't get over 100."
. Otherwise, it should return 'A'
if the score is greater than or equal to 90,
'B'
if greater than or equal to 80, 'C'
if greater than or equal to 70, 'D'
if greater than or equal to 60, and otherwise 'E'
.
For example, get_grade(90)
should return 'A'
.
Create a function called even_or_odd
that takes in a parameter num
. If num
is odd, return "This is odd."
, and if num
is even, return "This is even." ``.
For example, ``even_or_odd(-65)
should return "This is odd."
. Note: For this function, num
is solely an integer.
Write a function called even_or_odd
that takes in a parameter num
. If num
is odd, return "This is odd."
, and if num
is even, return "This is even." ``.
For example, ``even_or_odd(-65)
should return "This is odd."
. Note: For this function, num
is solely an integer.
Create a function called which_quadrant
that takes in parameters x
and y
and returns its corresponding quadrants in increasing order
(“Quadrant 1”, “Quadrant 2”, etc.). Refer to https://en.wikipedia.org/wiki/Quadrant_(plane_geometry) for quadrants on a coordinate
plane if needed. If coordinate is on the x or y axis, return "It's not in a quadrant."
. For example, which_quadrant(1, 100)
should return "Quadrant 1"
.
Write a function called which_quadrant
that takes in parameters x
and y
and returns its corresponding quadrants
(“Quadrant 1”, “Quadrant 2”, etc.). Refer to https://en.wikipedia.org/wiki/Quadrant_(plane_geometry) for quadrants on a coordinate
plane if needed. If coordinate is on the x or y axis, return "It's not in a quadrant."
. For example, which_quadrant(1, 100)
should return "Quadrant 1"
.
Create a function called axis_or_origin
that takes in parameters x
and y
. If both coordinates aren’t 0,
return "This coordinate is not on an axis. It's in a quadrant."
. If both coordinates are 0, return "This coordinate is the origin."
.
Lastly, if the coordinate isn’t in a quadrant and isn’t the origin, determine if the coordinate is on the x or y axis by returning
"This coordinate is on the (y-axis or x-axis)."
. Refer to https://www.math.net/x-and-y-axis for information on axes if needed.
For example, axis_or_origin(500, 0)
should return "This coordinate is on the x-axis."
.
Write a function called axis_or_origin
that takes in parameters x
and y
. If both coordinates aren’t 0,
return "This coordinate is not on an axis. It's in a quadrant."
. If both coordinates are 0, return "This coordinate is the origin."
.
Lastly, if the coordinate isn’t in a quadrant and isn’t the origin, determine if the coordinate is on the x or y axis by returning
"This coordinate is on the (y-axis or x-axis)."
. Refer to https://www.math.net/x-and-y-axis for information on axes if needed.
For example, axis_or_origin(500, 0)
should return "This coordinate is on the x-axis."
.
Create a function called num_to_day
that takes in a parameter num
. If num
is between 1-5 inclusive,
create a nested conditional statement that returns "This is a weekday, and it's (insert day here)."
, 1 being Monday through 5 being Friday.
If num
is 6 or 7, create a nested conditional statement that returns "It is the weekend, and it's (insert day here)."
,
6 being Saturday and 7 being Sunday. If none of the other conditions have been met, return "The number does not correspond to a day of the week."
.
For example, num_to_day(1)
should return "This is a weekday, and it's Monday."
.
Write a function called num_to_day
that takes in a parameter num
. If num
is between 1-5 inclusive,
create a nested conditional statement that returns "This is a weekday, and it's (insert day here)."
, 1 being Monday through 5 being Friday.
If num
is 6 or 7, create a nested conditional statement that returns "It is the weekend, and it's (insert day here)."
,
6 being Saturday and 7 being Sunday. If none of the other conditions have been met, return "The number does not correspond to a day of the week."
.
For example, num_to_day(1)
should return "This is a weekday, and it's Monday."
.