Page 516 - Computer Science V2.0 Class 11
P. 516
'''
Objective : To calculate the volume of a sphere
Input Parameter : radius – numeric value
Return Value : volume – numeric value
'''
volume = (4/3) * math.pi * radius**3
return volume
def sphereSurfaceArea(radius):
'''
Objective : To calculate the surface area of a sphere
Input Parameter : radius – numeric value
Return Value : surfaceArea – numeric value
'''
surfaceArea = 4 * math.pi * radius**2
return surfaceArea
radius = float(input("Enter the radius of the sphere: "))
volume = sphereVolume(radius)
surfaceArea = sphereSurfaceArea(radius)
print(f"Volume of the sphere: {volume:.2f}")
print(f"Surface area of the sphere: {surfaceArea:.2f}")
Program 23: Define a function that takes the temperature in Celsius as input and returns the temperature in Fahrenheit.
Invoke the function to print the temperature in Fahrenheit for the user-inputted temperature in Celsius.
Ans. def celsiusToFahrenheit(celsius):
'''
Objective : To convert celcius to fahrenheit
Input Parameter : celcius – numeric value
Return Value : None
'''
fahrenheit = (celsius * 9/5) + 32
return fahrenheit
celsius = float(input("Enter temperature in degrees Celsius: "))
fahrenheit = celsiusToFahrenheit(celsius)
print(f"Temperature in Fahrenheit: {fahrenheit:.2f} °F")
Program 24: Write a function txtDigit() that accepts a numeric digit as an argument and displays the digit in
words. For example, for the input 5, it should display: five.
Ans. def digitToText(digit):
'''
Objective : To display a digit in words
502 Touchpad Computer Science (Ver. 2.0)-XI

