This week will focus on simple exercises from Module 3.Create two functions, one for each of the following challenges:
1. Loops
Assume you have the following two-dimensional array:
array = [['.', '.', '.', '.', '.', '.'],
['.', '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', '.', '.', '.'],
['.', '.', '.', '.', '.', '.']]
And you want it to print out to the screen the following text art =
..OO.OO..
.OOOOOOO.
.OOOOOOO.
..OOOOO..
...OOO...
....O....
As you can see, you the first line is a print out of the first character from each array. The second line is a print out of the second character from each array. And so on. You will create your own text art. You can make the art look however you like, but the function must work the same way as in the example above.
Hint: You will need to use a loop in a loop in order to printgrid[0][0], thengrid[1][0], thengrid[2][0], and so on, up togrid[8][0]. This will finish the first row, so then print a newline. Then your program should printgrid[0][1], thengrid[1][1], thengrid[2][1], and so on. The last thing your program will print isgrid[8][5].
2. Coin Flip
Create a terminal coin flip game. The game should ask the user to make a selection, either '1' or '0'. Then the function should randomly select a value, again a '1' or a '0'. Then compare the values, and if they're equal you win, if they're not equal then the computer wins.