COS 102 Assignment Questions and Answers 2025
- Write a basic program that reads the value of F from the keyboard and compute the value C, given that C=5/9 (F – 32). Display the value of C and F on the screen.
- Write a basic program that reads in the radius of a circle in centimeters and compute the circumference and the area, given the area=Ï€r^2 and circumference =2Ï€r
Studentsdash
Answers
1) Fahrenheit → Celsius
# Fahrenheit to Celsius converter
F = float(input("Enter temperature in Fahrenheit: "))
C = (5.0 / 9.0) * (F - 32)
print(f"Fahrenheit: {F:.2f} F")
print(f"Celsius: {C:.2f} C")
2) Circle: area and circumference
import math
r = float(input("Enter radius in centimeters: "))
area = math.pi * r * r
circumference = 2 * math.pi * r
print(f"Radius: {r:.2f} cm")
print(f"Area: {area:.2f} cm^2")
print(f"Circumference: {circumference:.2f} cm")
If you have any questions you can chat Studentsdash on WhatsApp