Question
Python Problem 10.4 - Character Picture Grid Say you have a list of lists where each value in the inner lists is a one-character string,
Python Problem 10.4 - Character Picture Grid Say you have a list of lists where each value in the inner lists is a one-character string, like this:
grid=[ ['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 'O', '.'], ['.', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]
You can think of grid[x][y] as being the character at the x- and y-coordinates of a picture drawn with text characters. The (0, 0) origin will be in the upper-left corner, the x-coordinates increase going right, and the y-coordinates increase going down. Hint: You will need to use a loop in a loop in order to print grid[0][0], then grid[1][0], then grid[2][0], and so on, up to grid[8][0]. This will finish the first row, so then print a newline. Then your program should print grid[0][1], then grid[1][1], then grid[2][1], and so on. The last thing your program will print is grid[8][5]. Also, remember to pass the end keyword argument to print() if you dont want a newline printed automatically after each print() call. Problem 10.5 - Variable Number of Arguments Write a function called prod_all that takes any number of arguments and returns their product. Test the function by using these two tuples (separately) as arguments: (1, 2, 3, 4) & (4, 6, 8): prod_all(1, 2, 3, 4) # The answer should be 24 prod_all(4, 6, 8) # The answer should be 192 Problem 10.6 - Cumulative Sum Write a function called cumsum_twice() that takes a list of numbers and returns twice the cumulative sum; that is, a new list where the ith element is twice the sum of the first i + 1 elements from the original list. For example: t = [1, 2, 3] cumsum_twice(t) returns [2, 6, 12]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started