Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python Guidelines Think carefully about the order you will check different properties. You might want to write some pseudocode or perhaps draw a flowchart

image text in transcribed

image text in transcribed

image text in transcribed

in python

Guidelines Think carefully about the order you will check different properties. You might want to write some pseudocode or perhaps draw a flowchart if this works better for you. Think first, then implement Be careful what kinds of selection statements you use, and be sure to test your code with many examples. For instance, multiple if statements will not necessarily behave the same as a chain of if-elif-elif. When a specific test case isn't working, plug your code into the visualize 2 /4 t the code does, which lines run, which branches are taken. From built-in functions, you are allowed to call int(), float(), str() only. You are not allowed to import anything. You are not allowed to use loops or any feature that hasn't been covered in class yet Don't forget to review the "assignment basics" file Insert comments in the lines you deem necessary (hint: more than 0 are necessary) Assumptions You may assume that: The types of the values that are sent to the functions are the proper ones (length is an integer not a float, etc.), you don't have to validate them. The functions are going to be called with usable values (e.g. num_small is not negative, etc.). you don't have to validate them. Testing In this project testing will be slightly different from the previous one. There will be no user input or print statements this time. You'll given a number of tasks and for each of them you must implement one Python function. A template with the functions is provided to you. The tester will be calling your functions with certain arguments and will be examining the return values to decide the correctness of your code. Your functions should not ask for user input and should not print anything, just return a value based on the specification of the tasks. runCLUS In this project things are a bit different from the previous one. You won't write a monolithic program as you did in Programming Assignment 1, but you're going to implement the following functions. The signature of each function is provided below, do not make any changes to them otherwise the tester will not work properly. Keep in mind that you must not write a main body for your program in this project. You should only implement these functions, it is the tester that will be calling and testing each one of them. Last, be reminded that the generic structure of a function is the following def function_name(argl, arg2, etc.) . this line is the signature #commands go here #more commands result -... return result this line returns the result of your computations The following are the functions you must implement: intervals_relation (A_start, A_end, B_start, B_end) Description: The function checks whether intervals A and B have an overlap and returns a value that indicates what kind of overlap this is Parameters: A_start(int) and A_end (int) are the left and right limits of interval A, while B_start (int) and B_end (int) are the left and right limits of interval B respectively. All values are inclusive (.e. intervals are closed from both ends). Parameters A_start and A_end are guaranteed to be in order (the same holds for parameters B start and B_end), but this doesn't mean that interval A is necessarily positioned before interval B Return value of the two intervals do not overlap you return O. If one is enclosed entirely by the other you return 1. If there is a partial overlap you return-1. The return value is always an int + Examples intervals relation(1,8,2,8) intervals_relation (3,7,-1,2) intervals_relation (4,5,-2,4) 1 0 -1 + sphere quadrant(x,y,z) Description: Given the three coordinates of a 3D point decide what quadrant of a sphere this point lies in. The sphere (depicted in Figure 1) is centered on the origin (0,0,0) and has a radius of 1. Parameters: x (float)y (float),z (float) are the coordinates of the 3D point. All three parameters are guaranteed to have non zero values Return value: The color of the quadrant the 3D point lies in as a string containing one of the following values: blue, green, brown, magenta. Moreover, if the 3D point lies beneath the surface (ie the XY plane you see in the figure) prepend the above string with the string 'lower. Last, if the 3D point lies anywhere outside the sphere, return false (Hint use the extension of the pythagorean theorem to three-dimensional space to calculate the distance from the origin). Examples sphere quadrant(1,1,1) sphere quadrant(0.5, 0.5,0.5) sphere quadrant(-0.5, -0.5,-8.5) - False "green" "lower blue" +00 Yaxis.+00 X axis +00 Z axis -00 Figure 1 tile fitting(num small, num_large, length) Description: You have tiles of two different fixed sizes, 1ft and 5ft long, and you want to decide whether a certain number of these tiles can fit exactly a certain length ( we do not care about the other dimension). It's ok if you have more tiles than needed but not the opposite obviously Parameters num_snall (int) is the amount of the available small tiles (Ift), num_large (int) is the amount of the available large tiles (5ft), and length (int) is the length in ft) you want to cover Return value True if the available tiles can fit exactly the given length and False otherwise Examples tile_fitting(5,4,11) tile fitting(1,3,13) tile fitting(0,3,10) + True False True

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