Control Flow in Python Assignment
1.What are functions for? When would you want to use a function?
2.What's the output of the code in Figure A?
3.Write a function that returns "a is greater than b", "a is less than b", or "a is equal to b" depending on the values of two int input params a and b.
4.Write a function that prints out every number from 0 to an input parameter n (inclusive).
5.Write a function that converts an int num between 0-9 (inclusive) to its string equivalent (i.e., 1 -> "one").
6.What is wrong with the code in Figure A?
7.Write a for loop that prints each element in a list.
8.Write code that iterates through and prints unlimited lines of STDIN until ~BREAK~ is seen.
9.The provided code determines if a number is prime or not. Convert this code into a function is_prime(test_num).
10.Evaluate the boolean expressions shown in Figure A.
11.What do the boolean operators and, or, and not do in Python?
12.Provide values for a, b, and c that make the following statement evaluate as True:a + b == c and (c is a or c is b) and a != b
13.What's the difference between a for loop and a while loop in Python?
14.Write code that prints every number between 1 and an int input variable n (inclusive), with a designation indicating if the number is even or odd.
Did you like this question?
Was this helpful?
You may exit out of this review and return later without penalty.