Last active
November 22, 2015 12:27
-
-
Save fspeirs/9f7f2a0a0f9460abf288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
# Topic 3: Functions | |
# Exercise 3-01 | |
# | |
# 3-01-cointoss.py | |
#------------------------------------------- | |
# Instructions: | |
# You have been given a function called toss() that will print out "heads" or "tails" | |
# at random. | |
# | |
# You must modify the function called main() to call the toss() function three times straight. | |
#------------------------------------------- | |
def main(): | |
# Call the toss() function here. | |
# Make sure your calls to toss() are indented to line up with this comment. | |
# Do not edit below this line | |
from random import * | |
# Function: toss() | |
# Purpose: Prints "heads" or "tails" | |
def toss(): | |
if random() <= 0.5: | |
print "Heads" | |
else: | |
print "Tails" | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment