2.1 Functions - Lesson
Think you've got it?
- Short answer field
Unit 2: Control Flow - Review Assignment
1.What does the return keyword do within a function?
2.Write a function is_odd that returns True if an input parameter num is odd, or False otherwise.
3.Why is the following function probably not a good function?
python3<br>def multiply_two_numbers(a, b):<br> return a*b<br>
4.The provided function cool_func performs some logic pertaining to three arguments, a, b, and c. Call this function with the values a=1, b=10, and c=25.
5.What are functions for? When would you want to use a function?
6.What are functions for? When would you want to use a function?
7.Write a function that returns -10, 10, or 20 depending on the values of two int input params a and b.
8.Evaluate each of the following booleans:
python3<br>a = 10 >= 10<br>b = not a<br>c = not b<br>d = b or c<br>e = a and c<br>f = b and c<br>
9.Write code to set a variable a as True and a variable b as False.
10.Create a variable num_is_odd that evaluates as True if the variable num is odd or False otherwise.
11.What are the comparison operators in Python?
12.What do the boolean operators and, or, and not do in Python?
13.In Python, if/else statements are used to control the flow between two different options. How can we control the flow between more than two different options?
14.In Python, if/else statements are used to control the flow between two different options. How can we control the flow between more than two different options?
15.What is an if statement?
16.Write an if statement that prints 1 if two variables a and b have equal values, or 2 otherwise.
17.Adjust the value of the variable a in the following code so that -1 is printed.