# Constants
feet_in_a_mile = 5280
miles_jogged_per_day = 3
days_per_week = 6
# Total feet jogged in a week
total_feet_jogged = feet_in_a_mile * miles_jogged_per_day * days_per_week
print(total_feet_jogged)
# Time spent studying each day in hours, minutes, and seconds
hours = 2
minutes = 12
seconds = 20
# Convert everything to seconds
total_seconds_per_day = (hours * 60 * 60) + (minutes * 60) + seconds
print(total_seconds_per_day)
# Convert everything to seconds
total_seconds_per_day = (hours * 60 * 60) + (minutes * 60) + seconds
print(total_seconds_per_day)
# Dimensions of the rectangle
length = 55 # in inches
width = 21 # in inches
# Calculate the perimeter
perimeter = 2 * length + 2 * width
print(f"The perimeter of the rectangle is {perimeter} inches.")
# Given perimeter and dimensions for length and width
perimeter = 152 # in inches
length = 55 # in inches
# Calculate width using the perimeter formula: perimeter = 2l + 2w
width = (perimeter / 2) - length
# Calculate the area of the rectangle
area = length * width
# Print the area with unit
print(f"The area of the rectangle is {area} square inches.")
# Constants
pi = 3.14
radius = 28 # in inches
# Calculate the circumference of the circle
circumference = 2 * pi * radius
# Print the circumference with unit
print(f"The circumference of the circle is {circumference} inches.")
# Constants
pi = 3.14
radius = 108 # in inches
# Calculate the area of the circle
area = pi * (radius ** 2)
# Print the area with unit
print(f"The area of the circle is {area} square inches.")
# Variables
p = 10000 # principal amount in dollars
r = 12 # interest rate in percent
y = 20 # number of years
# Calculate the future value
future_value = p * (1 + 0.01 * r) ** y
# Print the future value with appropriate formatting
print(f"The future value of $10,000 compounded at 12% interest for 20 years is ${future_value:.2f}.")
# Assigning strings to variables
part1 = "My name is"
part2 = "John"
part3 = ", and also called Bear "
# Performing the concatenation
combined_string = part1 + " " + part2 + part3
print(combined_string)
# Input string
input_string = "John has 5 years experience in AI"
# Extracting the number from the string
import re
number = re.findall('\d+', input_string)[0]
# Printing the formatted result
print(f"John's Experience in AI = {number}")
The distance formula is given by: d = √((x2 - x1)2 + (y2 - y1)2)
and find the distance between: (5,7) and (-13,4)
import math
# Coordinates of the points
x1, y1 = 5, 7
x2, y2 = -13, 4
# Calculate the distance between the points
distance = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
# Print the distance
print(f"The distance between the points (5,7) and (-13,4) is {distance:.2f} units.")