Advertisement
Guest User

Functions challenge

a guest
Apr 2nd, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. from time import sleep
  2. import random
  3.  
  4.  
  5. # Haiku function
  6. def haiku():
  7.   haiku_quote = ["Snow in my shoe", "Abandoned", "Sparrow's nest"]
  8.   for item in haiku_quote:
  9.     sleep(1)
  10.     print(item)
  11.  
  12. haiku()
  13.  
  14.  
  15. # Calculate area of triangle function
  16. def cal_area():
  17.   a = float(input("Enter the height of the triangle"))
  18.   b = float(input("Enter the base of the triangle"))
  19.   area = (float(a) * float(b)) / 2
  20.   print(area)
  21.  
  22. cal_area()
  23.  
  24. # Coin flip function
  25. def coin_flip():
  26.   coin = random.randint(1,2)
  27.   if (coin == 1):
  28.     print("Heads")
  29.   else:
  30.     print("Tails")
  31.    
  32. coin_flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement