In: Computer Science
Code in Python
1. A function named get_score has been defined which consumes no parameters and returns an int value. Call get_score and print the result.
2.A function named area_rectangle has been defined which consumes two parameters that are both float values and returns a float value. Call area_rectangle with arguments of variables named length and width and print the result.
3. Assume a function called calculate_cone_volume is already defined. The function has 2 parameters: height and radius (in that order). calculate_cone_volume calculates the volume of a cone. V=pi*r^2*h/3
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Question 1:
#function get_score
def get_score():
#ask user to enter an integer
return int(input("Enter an Integer:"))
#call get_score and print Integer
print("Integer is ",get_score())
Output :
***********************************
Question 2:
#function area_rectangle
def area_rectangle(length,width):
#return area of rectangle
return length*width
#asking user to enter length
length=float(input("Enter Length:"))
#asking user to enter width
width=float(input("Enter Width:"))
#call area_rectangle and print Integer
print("Area of Rectangle is ",area_rectangle(length,width))
Output :
***************************
Question 3:
#function calculate_cone_volume
def calculate_cone_volume(h,r):
#return volume of cone
return 3.14*r*r*h/3
#asking user to enter radius
radius=float(input("Enter Radius:"))
#asking user to enter height
height=float(input("Enter Height:"))
#call calculate_cone_volume
print("Volume of cone is
",calculate_cone_volume(height,radius))
Output :
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.