Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def triangle_area():
- print("Calculates the area of a triangle ")
- height = input("Height of the triangle? ")
- base = input("Length of the base of the triangle? ")
- area = (int(base) * int(height))/2
- return area
- def coin_flip():
- if random.randint(0,1)==0:
- coin="heads"
- else:
- coin="tails"
- print ("The coin has fallen showing ", coin)
- def reverse_string(myString):
- new_String=''
- for i in myString:
- new_String= i + new_String
- return new_String
- def dice_roll(rolls):
- times=[0,0,0,0,0,0]
- for i in range(rolls):
- times[random.randint(0,5)]+=1
- return (times)
- print ("The area is ", triangle_area(), " m^2")
- coin_flip()
- text=input(" Write a nice word for your mates: ")
- print (" Are you sure is that :", reverse_string(text))
- rolled=int(input(" How many times do you want to roll the dices? "))
- print(" The histogram results are :",["1","2","3","4","5","6"], dice_roll(rolled))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement