need-help-with-python-2

Overview

This lab reviews previous concepts involving loops.

Python Functions and Scripts

Write and test Python functions for each of the following. When writing a function, include a docstring.

  1. Implement the function color_gallery that takes as a parameter a list of strings, each indicating a browser-compliant color. The function should generate and display a web page that shows all pair-wise combinations of colors from the list. Your generated page should have appropriate text labels for each displayed color. The actual formatting is up to you, provided that it’s reasonable.
  2. Craps is a dice-based game played in many casinos. Like blackjack, a player plays against the house. The game starts with the player throwing a pair of standard, six-sided die. If the player rolls a total of 7 or 11 in the first round, the player wins. If the player rolls a total of 2, 3, or 12 in the first round, the player loses. For all other roll values, the player must roll again to determine whether he/she has won or lost. In the second and subsequent rounds the player rolls the pair of dice again. If the player matches the roll value from the first round again, he/she wins. If the player rolls a 7, he/she loses. Play continues into another round until the initial roll is matched (for a win) or a 7 is rolled (for a loss).
    1. Write a function craps that takes no parameters, simulates one game of craps, and returns 1 if the player won and 0 if the player lost. It should also print a history of the rolls so that the player can verify that the function is doing the right thing.
    2. Next modify craps by adding an to it so that craps(True) produces the print output but that craps(False) does not. If it is called without a parameter, it should behave as described in the previous part (i.e. make its default value set to True). Finally, write a new function called quietCraps that doesn’t take any argments and simply returns 0 or 1 without the print results. The quietCraps function should simply make an appropriate call to craps.
    3. Finally, implement a function testCraps that takes a positive integer n as a parameter, simulates n games of craps using the quietCraps function, and returns the fraction of games the player won. The function must call the quietCraps function.

    PLEASE LOOK at the Attachment follow the format.