Advertisement
xavicano

Untitled

Jul 30th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import random
  2.  
  3. def triangle_area():
  4.     print("Calculates the area of a triangle ")
  5.     height = input("Height of the triangle? ")
  6.     base = input("Length of the base of the triangle? ")
  7.     area = (int(base) * int(height))/2
  8.     return area
  9.  
  10.    
  11. def coin_flip():
  12.     if random.randint(0,1)==0:
  13.         coin="heads"
  14.     else:
  15.         coin="tails"
  16.     print ("The coin has fallen showing ", coin)
  17.    
  18. def reverse_string(myString):
  19.     new_String=''
  20.     for i in myString:
  21.         new_String= i + new_String
  22.     return new_String
  23.    
  24. def dice_roll(rolls):
  25.     times=[0,0,0,0,0,0]
  26.     for i in range(rolls):
  27.         times[random.randint(0,5)]+=1
  28.     return (times)
  29.            
  30.    
  31. print ("The area is ", triangle_area(), " m^2")
  32.  
  33. coin_flip()
  34.  
  35. text=input(" Write a nice word for your mates: ")
  36. print (" Are you sure is that :", reverse_string(text))
  37.  
  38. rolled=int(input(" How many times do you want to roll the dices? "))
  39.  
  40. print(" The histogram results are :",["1","2","3","4","5","6"], dice_roll(rolled))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement