Advertisement
lubattillah

reflection to function

May 24th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. """
  2. This program creates a haiku function
  3. """
  4. def my_haiku():
  5. haiku=[]
  6. howmanylines=int(input("How many lines do you want your poem to have? "))
  7. for item in range(howmanylines):
  8. lines=input("Here is the line indexed to number "+str(item)+": ")
  9. item+=1
  10. haiku.append(lines)
  11. for line in haiku:
  12. print(line)
  13. my_haiku()
  14.  
  15. """
  16. This program calculates and prints out an area of triangle after
  17. asking inputs from the user, assumming the height and base are in cm
  18. """
  19. def area_triangle():
  20. height=int(input("What is the height of your triangle? "))
  21. base=int(input("What is the base of your triangle? "))
  22. area = 0.5*height*base
  23. print("The area of triangle is: ",area,"centimeter squared")
  24. area_triangle()
  25.  
  26. """
  27. function that simulates a coin flip.
  28. """
  29. import random
  30. def toss_coin():
  31. coin_face=["head","tail"]
  32. random.shuffle(coin_face)
  33. for item in coin_face:
  34. random.shuffle(coin_face)
  35. print(item)
  36.  
  37. toss_coin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement