Control Flow in Python Presentation (pages 9, 10)
Think you've got it?
Control Flow in Python Assignment
1.What's the output of the code in Figure A?
2.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.
3.Write a function that converts an int num between 0-9 (inclusive) to its string equivalent (i.e., 1 -> "one").
4.What is wrong with the code in Figure A?
5.Write code that iterates through and prints unlimited lines of STDIN until ~BREAK~ is seen.
6.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.
7.Write a function that prints out every number from 0 to an input parameter n (inclusive).
8.Write a for loop that prints each element in a list.
9.What's the difference between a for loop and a while loop in Python?
10.What are functions for? When would you want to use a function?
11.The provided code determines if a number is prime or not. Convert this code into a function is_prime(test_num).
12.Evaluate the boolean expressions shown in Figure A.
13.What do the boolean operators and, or, and not do in Python?
14.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