~1 min read • Updated Oct 1, 2025
Program Overview
This Python program calculates the value of the expression:
y = b × sin(a)
It reads values for a and b from the user and uses the math.sin() function to compute the result.
Note: The input angle a is expected in radians.
Python Code:
import math
# Read inputs from user
a = float(input("Enter value for a (in radians): "))
b = float(input("Enter value for b: "))
# Calculate y = b × sin(a)
y = b * math.sin(a)
# Display result
print("\n--- Result ---")
print(f"y = {y:.4f}")
Sample Output:
Enter value for a (in radians): 1.5708
Enter value for b: 5
--- Result ---
y = 5.0000
Step-by-Step Explanation:
- The user enters values for a and b
- The program calculates sin(a) using the math module
- The result is multiplied by b to compute y
- The final output is printed with four decimal places
Written & researched by Dr. Shahin Siami