Task1.
1
Program:
principal = float(input("Enter the principal amount:"))
rate = float(input("Enter the rate of interest: "))
time = float(input("Enter the time in years: "))
compound_ interest = principal *((1 +rate/100) ** time)- principal
print("The compound interest is:", compound_interest)
output:
1.2
def calculate_total_cost(x, y):
return x * y
# Input the number of test cases
t = int(input("Enter the number of test cases: "))
# Iterate through each test case
for _ in range(t):
# Input for each test case
x, y = map(int, input("Enter x and y separated by space: ").split())
# Calculate and print the total amount for the current test case
total_amount = calculate_total_cost(x, y)
print("Total cost:", total_amount)
output:
1.3
import math
def calculate_area_in_acres(radius_in_feet):
# Convert radius from feet to acres (1 acre = 43,560 square feet)
area_in_acres = [Link] * (radius_in_feet ** 2) / 43560
return area_in_acres
# Input the radius of the field in feet
radius_in_feet = float(input("Enter the radius of the field in feet: "))
# Calculate and print the area of the field in acres
area_in_acres = calculate_area_in_acres(radius_in_feet)
# Using f-string to embed variables in a string
print(f"The area of the field is: {area_in_acres:.2f} acres")
output:
1.4
import math
def calculate_distance(x1, y1, x2, y2):
# Use the distance formula: √[(x2 - x1)² + (y2 - y1)²]
distance = [Link]((x2 - x1)*2 + (y2 - y1)*2)
return distance
# Input the coordinates of Ram
x_ram = float(input("Enter the X-coordinate of Ram: "))
y_ram = float(input("Enter the Y-coordinate of Ram: "))
# Input the coordinates of Sita
x_sita = float(input("Enter the X-coordinate of Sita: "))
y_sita = float(input("Enter the Y-coordinate of Sita: "))
# Calculate the distance
distance_between_them = calculate_distance(x_ram, y_ram, x_sita, y_sita)
# Print the distance using f-string, rounded to 2 decimal places
print(f"The distance between Ram and Sita is: {distance_between_them:.2f}")
Output: