Question

In: Computer Science

Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and...

Please answer using python 3 and def functions!

  1. Lab 2 Drill 3: (function practice) create and use a function named highest() that takes three inputs and returns the highest number. After you have got it working, try calling the function with inputs ‘hat’, ‘cat’, ‘rat’.

Solutions

Expert Solution

ANSWER: Here I am giving you the code and output please like it if you still have any doubt then comment on it before going to downvote.

CODE:

num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
num3 = input("Enter third number: ")
def highest(num1,num2,num3):
if (num1 > num2) and (num1 > num3):
largest = num1
elif (num2 > num1) and (num2 > num3):
largest = num2
else:
largest = num3

return largest

print("The largest number is",highest(num1,num2,num3))

CODE & OUTPUT:


Related Solutions

USING PYTHON 3.7 AND USING def functions. Write a function called GPA that calculates your grade...
USING PYTHON 3.7 AND USING def functions. Write a function called GPA that calculates your grade point average (GPA) on a scale of 0 to 4 where A = 4, B = 3, C = 2, D = 1, and F = 0. Your function should take as input two lists. One list contains the grades received in each course, and the second list contains the corresponding credit hours for each course. The output should be the calculated GPA. To...
In python please Problem Create two server objects using the class create a function, biggest_server_object_sum, outside...
In python please Problem Create two server objects using the class create a function, biggest_server_object_sum, outside of the ServerClass class, that: 1. Takes the IP 2. Sums the octets of the IP together (example 127.0.0.1 = 127+0+0+1 = 128) 3. Returns the Server object with the larger sum Example: server_one = ServerClass("127.0.0.1") server_two = ServerClass("192.168.0.1") result = biggest_ip_sum(server_one, server_two) print(result) Hint Modify get_server_ip in the previous problem. -------------------- Please use this code to start class ServerClass: """ Server class for...
2. working with databases and files in python a) Write a function with prototype “def profound():”...
2. working with databases and files in python a) Write a function with prototype “def profound():” that will prompt the user to type something profound. It will then record the date and time using the “datetime” module and then append the date, time and profound line to a file called “profound.txt”. Do only one line per function call. Use a single write and f-string such that the file contents look like: 2020-10-27 11:20:22 -- Has eighteen letters does 2020-10-27 11:20:36...
Using the Iris dataset in R; PLEASE CREATE YOUR OWN FUNCTION USING FORMULAS INTEAD OF FUNCTIONS...
Using the Iris dataset in R; PLEASE CREATE YOUR OWN FUNCTION USING FORMULAS INTEAD OF FUNCTIONS THAT ARE BUILT IN R ,,,,,PLEASE TRY PLEASE a Carry out a hypothesis to test if the population sepal length mean is 6.2 at α = 0.05. Interpret your results. b Carry out a hypothesis to test if the population sepal width mean is 4 at α = 0.05. Interpret your results. c Carry out a hypothesis to test if the population sepal width...
I need to write these three functions in Python using turtle module. def line(t, coord1, coord2)...
I need to write these three functions in Python using turtle module. def line(t, coord1, coord2) t is a turtle object passed in coord1 and coord2 are 2-element lists that represent x, y coordinates draws a line from coord1 to cord2 def poly(t, *coords) t is a turtle object passed in *coords is any number of x, y coordinates each as a 2-element list draws a polygon based on coords (will close off polygon by drawing a line from last...
python practice! 1. Create a function that takes a user choice and one number as parameters...
python practice! 1. Create a function that takes a user choice and one number as parameters and returns the operation result. -Square: print the number square -Sqrt: print the square root of the number -Reverse: reverse the sign of the number (pos or neg) and print it Note: Detect invalid choices and throw an error message – Number can be anything. 2. Create a function that takes a user choice and two numbers (start and end) as parameters. For example,...
Python 3 Forming Functions Define and complete the functions described below. * function name: say_hi *...
Python 3 Forming Functions Define and complete the functions described below. * function name: say_hi * parameters: none * returns: N/A * operation: just say "hi" when called. * expected output: >>> say_hi() hi * function name: personal_hi * parameters: name (string) * returns: N/A * operation: Similar to say_hi, but you should include the name argument in the greeting. * expected output: >>> personal_hi("Samantha") Hi, Samantha * function name: introduce * parameters: name1 (string) name2 (string) * returns: N/A...
Python 3 Functions that give answers Define and complete the functions described below. * function name:...
Python 3 Functions that give answers Define and complete the functions described below. * function name: get_name * parameters: none * returns: string * operation: Here, I just want you to return YOUR name. * expected output: JUST RETURNS THE NAME...TO VIEW IT YOU CAN PRINT IT AS BELOW >>> print(get_name()) John * function name: get_full_name * parameters: fname (string) lname (string) first_last (boolean) * returns: string * operation: Return (again, NOT print) the full name based on the first...
Language: Python 3 (Please structure answer as basic as possible) Write a function that involves two...
Language: Python 3 (Please structure answer as basic as possible) Write a function that involves two arguments, named changeTheCase(myFile, case), that takes, as arguments, the name of a file, myFile, and the case, which will either be “upper” or “lower”. If case is equal to “upper” the function will open the file, convert all characters on each line to upper case, write each line to a new file, named “upperCase.txt”, and return the string “Converted file to upper case.” If...
USING PYTHON Write a program to create a number list. It will call a function to...
USING PYTHON Write a program to create a number list. It will call a function to calculate the average values in the list. Define main ():                        Declare variables and initialize them                        Create a list containing numbers (int/float)                        Call get_avg function that will return the calculated average values in the list.                                       Use a for loop to loop through the values in the list and calculate avg                        End main()
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT