Question

In: Computer Science

Code in Python 1. A function named get_score has been defined which consumes no parameters and...

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

Solutions

Expert Solution

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.


Related Solutions

Define a Python function named matches that has two parameters. Both parameters will be lists of...
Define a Python function named matches that has two parameters. Both parameters will be lists of ints. Both lists will have the same length. Your function should use the accumulator pattern to return a newly created list. For each index, check if the lists' entries at that index are equivalent. If the entries are equivalent, append the literal True to your accumulator. Otherwise, append the literal False to your accumulator. Hint: Since you must use the same index with each...
Python Problem 3 Write a function named enterNewPassword. This function takes no parameters. It prompts the...
Python Problem 3 Write a function named enterNewPassword. This function takes no parameters. It prompts the user to enter a password until the entered password has 8-15 characters, including at least one digit. Tell the user whenever a password fails one or both of these tests.
Write a function named "check_matrix" which takes two matrices as parameters and returns 1 if the...
Write a function named "check_matrix" which takes two matrices as parameters and returns 1 if the matrices are same or 0 otherwise. Set appropriate parameters and return type if necessary.
Write a Python program: The function is named validity(). It receives 2 floating point parameters, min...
Write a Python program: The function is named validity(). It receives 2 floating point parameters, min and max, from the program that invoked it. The function asks the user to enter a float number. Using a while loop it checks whether the number is valid (between min and max, inclusive). If not valid, the while loop uses this statement to prompt for a new number: num = float (input (" Enter a number that is at least :"+ str(min) +...
IN PYTHON Create a function called biochild.  The function has as parameters the number m...
IN PYTHON Create a function called biochild.  The function has as parameters the number m and the lists biomother and biofather.  The biomother and biofather lists contain 0’s and 1’s.  For example: biomother = [1,0,0,1,0,1] and biofather = [1,1,1,0,0,1]  Both lists have the same length n.  The 0's and 1's represent bits of information (remember that a bit is 0 or 1).  The function has to generate a new list (child).  The child...
1. Implement the function calculate_score that consumes three parameters, two strings and a list. The strings...
1. Implement the function calculate_score that consumes three parameters, two strings and a list. The strings will each be ONE character and will represent a nucleotide. The list will be a nested int list representing a 4x4 score matrix. This function will return the value (int) from the nested int list at the location of the two referenced nucleotides. a. An example call to calculate_score would be calculate_score(“A”, “T”, score_matrix). If we look at the alignment score table in the...
Write a function named “compileStats” that has 4 parameters: a vector of integers, an integer representing...
Write a function named “compileStats” that has 4 parameters: a vector of integers, an integer representing the smallest value contained in the vector, an integer representing the largest value contained in the vector, and a double that represents the average of the values in the vector. The compileStats function will not “return” a value, it will set the Pass By Reference parameters to the correct values (smallest, largest, and average). Use the following main function in driver1b.cpp as a starting...
Sovle with python 3.8 please. 1, Write a function called same_without_ends that has two string parameters....
Sovle with python 3.8 please. 1, Write a function called same_without_ends that has two string parameters. It should return True if those strings are equal WITHOUT considering the characters on the ends (the beginning character and the last character). It should return False otherwise. For example, "last" and "bask" would be considered equal without considering the characters on the ends. Don't worry about the case where the strings have fewer than three characters. Your function MUST be called same_without_ends. You...
Write code to define a function named mymath. The function has three arguments in the following...
Write code to define a function named mymath. The function has three arguments in the following order: Boolean, Integer, and Integer. It returns an Integer. The function will return a value as follows: 1. If the Boolean variable is True, the function returns the sum of the two integers. 2. If the Boolean is False, then the function returns the value of the first integer - the value of the second Integer.
In PYTHON Write an algorithm for a function called removeAll which takes 3 parameters: an array...
In PYTHON Write an algorithm for a function called removeAll which takes 3 parameters: an array of array type, a count of elements in the array, and a value. As with the remove method we discussed in class, elements passed the count of elements are stored as None. This function should remove all occurrences of value and then shift the remaining data down. The last populated element in the array should then be set to None. The function then returns...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT