Skip to content

Instantly share code, notes, and snippets.

@fspeirs
Last active November 22, 2015 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fspeirs/9f7f2a0a0f9460abf288 to your computer and use it in GitHub Desktop.
Save fspeirs/9f7f2a0a0f9460abf288 to your computer and use it in GitHub Desktop.
#!/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