018/Python-Projects

/Python-Projects/PythonProjects/PythonProjects/PythonProjects/Project 1 - Basic Functions/Project1-Functions.py
import math
from random import random

# This program will calculate the area of a circle given a radius
# The function is called area_of_circle(radius) and returns the area
def area_of_circle(radius):
area = math.pi * (radius ** 2)
return area

# This function will calculate the area of a rectangle given its width and height
# The function is called area_of_rectangle(width, height) and returns the area
def area_of_rectangle(width, height):
area = width * height
return area

# This function will calculate the area of a triangle given its base and height
# The function is called area_of_triangle(base, height) and returns the area
def area_of_triangle(base, height):
area = (1/2) * base * height
return area

# This function will calculate the area of a square given its side length
# The function is called area_of_square(side) and returns the area
def area_of_square(side):
area = (side ** 2)
return area

# This function will calculate the perimeter of a circle given a radius
# The function is called perimeter_of_circle(radius) and returns the perimeter
def perimeter_of_circle(radius):
perimeter = 2 * math.pi * radius
return perimeter

# This function will calculate the perimeter of a rectangle given its width and height
# The function is called perimeter_of_rectangle(width, height) and returns the perimeter
def perimeter_of_rectangle(width, height):
perimeter = 2 * (width + height)
return perimeter

# This function will calculate the perimeter of a triangle given its base and height
# The function is called perimeter_of_triangle(base, height) and returns the perimeter
def perimeter_of_triangle(base, height):
perimeter = base + height + math.sqrt(height 2 + base 2)
return perimeter

# This function will calculate the perimeter of a square given its side length
# The function is called perimeter_of_square(side) and returns the perimeter
def perimeter_of_square(side):
perimeter = 4 * side
return perimeter

# This function will calculate the circumference of a circle given a radius
# The function is called circumference_of_circle(radius) and returns the circumference
def circumference_of_circle(radius):
circumference = 2 * math.pi * radius
return circumference

# This function will calculate the circumference of a square given its side length
# The function is called circumference_of_square(side) and returns the circumference
def circumference_of_square(side):
circumference = 4 * side
return circumference

# This function will calculate the volume of a cube given its side length
# The function is called volume_of_cube(side) and returns the volume
def volume_of_cube(side):
volume = (side ** 3)
return volume

# This function will calculate the volume of a rectangular prism given its width, height, and depth
# The function is called volume_of_rectangular_prism(width, height, depth) and returns the volume
def volume_of_rectangular_prism(width, height, depth):
volume = width * height * depth
return volume

# This function will calculate the volume of a cylinder given its radius and height
# The function is called volume_of_cylinder(radius, height) and returns the volume
def volume_of_cylinder(radius, height):
volume = math.pi * (radius ** 2) * height
return volume

# This function will calculate the volume of a sphere given its radius
# The function is called volume_of_sphere(radius) and returns the volume
def volume_of_sphere(radius):
volume = (4 / 3) * math.pi * (radius ** 3)
return volume

# This function will calculate the surface area of a sphere given its radius
# The function is called surface_area_of_sphere(radius) and returns the surface area
def surface_area_of_sphere(radius):
surface_area = 4 * math.pi * (radius ** 2)
return surface_area

# This function will calculate the surface area of a cube given its side length
# The function is called surface_area_of_cube(side) and returns the surface area
def surface_area_of_cube(side):
surface_area = 6 * (side ** 2)
return surface_area

# This function will calculate the surface area of a rectangular prism given its width, height, and depth
# The function is called surface_area_of_rectangular_prism(width, height, depth) and returns the surface area
def surface_area_of_rectangular_prism(width, height, depth):
surface_area = 2 * (width * height + height * depth + depth * width)
return surface_area

# This function will calculate the surface area of a cylinder given its radius and height
# The function is called surface_area_of_cylinder(radius, height) and returns the surface area
def surface_area_of_cylinder(radius, height):
surface_area = 2 * math.pi * (radius * height) + 2 * math.pi * (radius ** 2)
return surface_area

# This function will calculate the surface area of a cone given its radius and height
# The function is called surface_area_of_cone(radius, height) and returns the surface area
def surface_area_of_cone(radius, height):
surface_area = math.pi * radius * (radius + math.sqrt(height 2 + radius 2))
return surface_area

# This function will calculate the surface area of a pyramid given its base length, base width, and height
# The function is called surface_area_of_pyramid(base_length, base