Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python code In this lab, you will define functions which you will call from another function. A. In the file lab5.py, write a function named

image text in transcribed
python code
In this lab, you will define functions which you will call from another function. A. In the file lab5.py, write a function named distance() that takes four float parameters x1, 41, X2, 42, which represent the two points on the plane (X1, y1) and (x2, y2) and returns the distance between the two points. The distance D is given by this formula: D = (x2 - 1)2 + (y2 - y2). The template of the function is def distance(x1, yi, x2, y2): B. Write the usual main function that will read as input the four values x1, yi, x2, y2, one at a time from the user. They should be considered float values, although integer values may be given. For example, for reading xl you could use the usual: x1 = eval(input("Input x1: ")) It will then output the two points and the distance between them, as in this example: The distance between point (3, 4) and (5,6) is 2.8284271247461903 C. In the same file above main(, write another function even_or_odd that will take as parameter a float number x. If round(x) is an even number, it should output The given number x is closest to an the even number y. else, it should output The given number x is closest to an the odd number y. where x and y should be the actual values of the input and the rounded number, respectively. D. Add to the main() function so that after it outputs the distance between the two points, it calls the function even_or_odd(D), where parameter D is the distance between the two points. E. Make sure you include a header in Lab5.py, as always, along these lines: 5-1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions