bool(0) a. True *b. False
bool(961) *a. True b. False
bool(961) *a. True b. False
bool(961) *a. True b. False
bool(961) *a. True b. False
bool("orange") *a. True b. False
bool("False") *a. True b. False
bool("") a. True *b. False
bool(0.0000001) *a. True b. False
bool(0.0000001) *a. True b. False
bool(0.0) a. True *b. False
int(bool(3482)) a. 0 *b. 1 c. 3482
# -------------------------- # Module name: my_method1.py def square(n): return n ** 2 # ------------------------- # Module name: main.py import my_method1 print(my_method1.square(7)) # ------------------------Ans: Arguments are values passed in to a method when it is called. Parameters are variables passed in to a method when it is defined with a def statement. The parameters tell the method what to do with the arguments.
# --------------------- # Module: my_method2.py def sum_array(the_array): total = 0 for n in the_array: total += n return total # -------------------- # Module: main.py from my_method2 import sum_array a = [1, 2, 3, 4] print(sum_array(a)) # --------------------Ans: the_array is the parameter for the sum_array method. a is the argument for the sum_array method in main; sum_array(a) is the argument of the print method. total and n are local variables in main.
["Frame0", [7, 2], [8, 2], [10], [10], [10], [10], [10], [9, 1], [10], [10], [7, 3]]"Frame0" is prepended to the array as a placeholder for Frame 0, which is not actually a frame in a bowling game. This is so the index of the first frame [7, 2] is 1. What is the score for each frame? Ans:
Frame Number | Frame as List | Frame Score |
---|---|---|
1 | [7, 2] | 9 |
2 | [8, 2] | 8 + 2 + 10 = 20 |
3 | [10] | 10 + 10 + 10 = 30 |
4 | [10] | 10 + 10 + 10 = 30 |
5 | [10] | 10 + 10 + 10 = 30 |
6 | [10] | 10 + 10 + 9 = 29 |
7 | [10] | 10 + 9 + 1 = 20 |
8 | [9, 1] | 9 + 1 + 10 = 20 |
9 | [10] | 10 + 10 + 7 = 27 |
10 | [10] | 10 + 7 + 3 = 20 |
Bonus | [7, 3] |
def frame_score(the_frame, next_ball_1, next_ball_2): # Case of a strike if the_frame[0] == 10: return 10 + next_ball_1 + next_ball_2 # Case of a spare elif the_frame[0] + the_frame[1] == 10: return 10 + next_ball_1You add the third case of an open frame.