Advertisement
kevinbocky

triangle_reverse_dice.py

Jan 23rd, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #define the triangle function, to calculate the surface area
  2. def triangle():
  3. base = input("Enter the base measurement of the triangle in cm ")
  4. height = input("Enter the height measurement of the triangle in cm ")
  5. surface = 0.5 * int(base) * int(height)
  6. print(str(surface) + " cm3 ")
  7.  
  8. triangle()
  9.  
  10. #define the reverse function, enter word,gets printed in reverse order
  11. def reverse():
  12. question = input("input your word here so we can reverse it ")
  13. print(question[::-1])
  14.  
  15. reverse()
  16.  
  17. #define the roll of dice function, ask input for number of attempts, generate random numbers
  18. def roll_dice():
  19. import random
  20. from time import sleep
  21. outcome = [2,3,4,5,6,7,8,9,10,11,12]
  22. loop = input("how many times do you want to roll the dice? ")
  23. for tries in range(int(loop)):
  24. print(random.choice(outcome))
  25. sleep(1)
  26.  
  27. roll_dice()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement