Ada Lovelace Code Snippets
Ada Lovelace's Code Snippets
Computing the Trajectory of a Projectile Motion
# Define the initial velocity and angle of the projectile
v_i = 10 # m/s
theta = 45 # degrees
# Define the acceleration due to gravity
g = 9.8 # m/s^2
# Calculate the range and time of flight
range = (v_i^2 * sin(2 * theta)) / g
time = (2 * v_i * sin(theta)) / g
# Print the results
print("Range:", range, "m")
print("Time of flight:", time, "s")
Calculating the Area of a Circle
# Import the math module
import math
# Define the radius of the circle
r = 5 # meters
# Calculate the area
area = math.pi * r^2
# Print the result
print("Area of the circle:", area, "square meters")