This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#How to calculate area of an arbitary triangle | |
import math | |
a = input("Enter value a : ") | |
a = float(a) | |
b = input("Enter value b : ") | |
b = float(b) | |
c = input("Enter the degree : ") | |
c = float(c) | |
c = math.radians(c) | |
area = 1/2 * a * b * math.sin(c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Area of an equilateral triangle | |
import math | |
#to use math function must import lib math | |
h = input("Enter the height of equilateral triangle : ") | |
#to input value height and store to variable h | |
h = float(h) | |
#convert value have input to be float | |
a = (h**2 * math.sqrt(3))/3 | |
#formula to calculate the area | |
print ("The area of an equilateral triangle : ",a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Area Of A Trapezoid | |
h = input("Enter the height of the trapezoid : ") | |
#input value height of the trapezoid | |
h = float(h) | |
#convert h into float value | |
lb = input("Enter the lenght of the bottom base : ") | |
#input value lenght bottom base | |
lb = float(lb) | |
#convert lenght bottom base to float value | |
lt = input("Enter the lenght of the top base : ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import exit | |
while True: | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
pygame.quit() | |
exit() | |
#PUT THE FOLLOWING CODE AT THE END OF PYGAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Welcome to Camel!","\nYou have stolen a camel to make your way across the great Mobi desert.","\nThe natives want their camel back and are chasing you down! Survive your","\ndesert trek and out run the natives.") | |
import random | |
done = False | |
miles_traveled = 0 | |
thirst = 0 | |
camel_tired = 0 | |
natives_traveled = -20 | |
drink = 5 | |
natives_up = random.randrange(0, 10) | |
full_speed = random.randrange(10, 20) |