Example 1: There are 5280 feet in a mile. If John jogs 3 miles every day and he does this 6 days in a week, Write a Python code to find the total number of feet he jogs in a week.
      
          # 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)
          
Example 2: John studies 2 hours, 12 minutes and 20 seconds every day. Write a Python code to calculate the number of seconds he spends in studies every day?
      
          
# 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)
          
Example 3:The perimeter of a rectangle is 2l + 2w, where l is the length, and w is the width. Write a Python statement that calculates and prints the perimeter, given that the length=55inches, and width=21 inches.
      
          # 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.")          
Example 4: if the perimeter of a Rectangle = 152 inches, write a Python code that calculates its Area, print your answer with respective unit.
      
          # 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.")
          
Example 5: Given that the circumference of a circle is 2πr where r is the radius of the circle. Write a Python statement that calculates and prints the circumference in inches of a circle whose radius is 28 inches. Assume that the constant π=3.14
      
          # 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.")
          
Example 6:The area of a circle is πr^2 where r is the radius of the circle. (The raised 2 in the formula is an exponent.) Write a Python statement that calculates and prints the area in square inches of a circle whose radius is 108 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.")
          
Example 7:Given p dollars, the future value of this money when compounded yearly at a rate of r percent interest for y years is p(1 + 0.01r)^y. Write a Python statement that calculates and prints the value of 10000 dollars compounded at 12 percent interest for 20 years. Convert this question to latex code, and then write a python code to calculate the required.
      
          # 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}.")
          
Example 8: Write a single Python statement that combines the three strings "My name is", "John" ", also called Bear " into one larger string "My name is John, and also called Bear " and prints the result.
      
          # 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)
          
Example 9: write a python code that take the number out of this string, "John has 5 years experience in AI", and prints it out as, John's Experience in AI = 5.
      
          # 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}")
          
Example 10: use the distance formula

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.")