Advertisement
farrismp

Course1

Apr 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import random
  3.  
  4. def linebyline(poem):
  5. # Function to print each line of a haiku
  6. for line in poem:
  7. print(line)
  8.  
  9. def triangle():
  10. # Function to calculate area of triangle
  11. height = float(input("what is the height of the triangle ? "))
  12. base = float(input("and what is the base length of the triangle ? "))
  13. area = (base / 2) * height
  14. print("The area of that triangle would be {} ".format(area))
  15.  
  16. def flip():
  17. # Function to simulate a coin flip
  18. side = random.randint(0,1)
  19. if side == 0:
  20. print("Heads")
  21. else:
  22. print("Tails")
  23.  
  24. # Now call the functions
  25. text = ('Whitecaps on the bay','A broken signboard banging','In the April wind.')
  26. linebyline(text)
  27. triangle()
  28. flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement