Page 437 - Computer Science Class 11 With Functions
P. 437
'''
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
Input Parameter : digit-numeric value
Return Value : digitWords
'''
digitWords = {
'0': 'zero',
'1': 'one',
Practical 435

