Order for this Paper or similar Assignment Help Service

Fill the order form in 3 easy steps - Less than 5 mins.

Posted: September 1st, 2022

Preparations
Learn this week’s course notes.
Learn the primary a part of Chapter 2 (as much as -while loop statements-) in Automate the Boring Stuff with Python.
Job 1
On this job, you’ll create a perform find_longest_words with three parameters within the file uke_02_oppg_1.py. The perform prints the longest phrases. If a number of phrases have the longest size, this system should print all of the phrases.
For instance, a name to find_longest_words(-Recreation-, -Motion-, -Champion-) will print
whereas a name to find_longest_words(-apple-, -carrot-, -pineapple-) will print
and a name to find_longest_words(-4-, -5-, -9-) will print
Job 2
The rule for calculating whether or not a 12 months is a bissextile year or not is as follows:
Often, a 12 months divisible by four is a bissextile year (for instance, 1996 was a bissextile year);
aside from years which are additionally divisible by 100 (for instance, 1900 just isn’t a bissextile year);
but when the 12 months that’s divisible by 100 can also be divisible by 400, then it’s nonetheless a bissextile year (for instance, 2000 is a bissextile year).
n the file uke_02_oppg_2.py create a perform is_leap_year(12 months) which takes in a 12 months quantity and returns True if it’s a bissextile year, and False if not.
Check your code by including these strains to the underside of the file:
Trace
Use the modulus operator (%) to find out whether or not an integer is divisible by one other. Verify course notes in regards to the operator %.
PS: If every thing is appropriately, this system will print
Testing is_leap_year… OK
Job three
It’s normally stated that one human 12 months corresponds to 7 canine years. This doesn’t bear in mind that canine turn out to be adults when they’re about 2 years previous. Due to this fact, it could be higher to depend each the primary 2 human years as 10.5 canine years every, and after that depend every human 12 months as four canine years.
Within the file uke_02_oppg_3.py, create the perform human_to_dog_years with one parameter representing the variety of human years. Let the perform return what number of canine years this corresponds to.
Check your code by including these strains to the underside of the file:
PS: If an assert fails, it may be a good suggestion to see what the outcome truly was. Add a print assertion that shows the results of human_to_dog_years earlier than the asserts
Job four
Right here we are going to do nearly the identical factor as in job 1 once more, however with a small distinction. Within the file uke_02_oppg_4.py, you have to create a perform find_first_longest_word which takes in three strings as parameters and prints out the longest phrase. But when a number of phrases have the longest size, this system ought to solely print the primary phrase that has the longest size.
Instance run:
Job 5a
Our eyes understand electromagnetic radiation with a wavelength from 380 to 740 nanometers, or with a frequency from 405 to 790 terahertz. This space is named seen mild or simply mild. electromagnetic radiation in seen mild is transformed into colours within the brains of people and animals. The desk beneath reveals the place the completely different colours of seen mild lie within the spectrum. Wikipedia.
Within the file uke_02_oppg_5.py, create the perform wavelength_to_color with a parameter that represents the wavelength worth in nanometers (nm). The perform ought to return which coloration in seen mild the wavelength corresponds to. In the event you get a worth that’s precisely on the border between two colours, you have to select the colour with the shortest wavelength of the 2. In the event you get a worth that’s exterior the seen mild vary, the perform should return None.
Check your code by including these strains to the underside of the file:
Job 5b
Within the file uke_02_oppg_5.py you have to create a perform frequency_to_color which has the identical habits because the perform in job a, however which as an alternative has a parameter representing a wave frequency in terahertz (THz). The perform ought to return which coloration in seen mild the wave frequency represents.
On this perform, you have to first convert from terahertz to nanometers, after which reuse the perform you wrote in train a to search out the colour.
The system to transform from Hz to meters is
the place ? is wavelength in meters, f is frequency in Hz, and c = 3×108 m/s is velocity of sunshine.
Check your code by including these strains to the underside of the file:
Train 5c
On this job, you’ll use the features from 5a and 5b to course of completely different inputs from customers. Within the file uke_02_oppg_5.py, write a perform frequency_or_wavelength_to_color with out parameters that asks the consumer for a unit, both nanometer (‘nm’) or terahertz (‘THz’), after which a worth (a quantity). The perform ought to print out which coloration in seen mild that unit and worth belong to. In the event you get a unit that isn’t nm or THz, your program ought to inform the consumer that the unit have to be both nm or THz, and this system ought to finish execution (see examples beneath for actual wording). If the consumer enters a wavelength or frequency that’s exterior the spectrum, a message should even be given about this (see examples).
Make a name to this perform on the finish of the file, in order that once you run the uke_02_oppg_5.py file solely that is printed to the display (take away any calls to print you have got used to check earlier features in a and b).
Instance runs:
frequency_or_wavelength_to_color()
Train 6
Within the file uke_02_oppg_6.py, create a perform is_even_positive_int that has a parameter x. The perform ought to return True if x is a optimistic even variety of kind int, and False in any other case.
Check your code by including these strains to the underside of the file:
Trace
• To examine whether or not a variable x is of kind int, use kind(x) == int.
• Use the % operator to find out whether or not a quantity is even or odd.
Job 7
Within the file uke_02_oppg_7.py, write a perform is_legal_triangle that has three parameters. Let the perform return True if the three parameters characterize optimistic numbers that may characterize the size of the edges of a triangle, and False if such a triangle can not exist. Notice from the triangle inequality that the sum of any selection of two sides is at all times better than the third facet.
The perform ought to work if the arguments are both float or int; if an argument has a special kind, the perform should return False, and never crash.
Check your code by including these strains to the underside of the file:
Trace
• Begin by checking that the arguments have the proper kind. For every parameter, examine if the sort is int or float, and if not return False.
• For all sides size, examine that the sum of the opposite two facet lengths is bigger. In the event you discover a facet size that is the same as or longer than the sum of the opposite two, return False.
• Lastly, you simply return True
Job 8a
A hyperrectangle is a rectangle whose sides are horizontal and vertical (not rotated). We are able to characterize a hyperrectangle with two coordinates (x_0, y_0)(x zero,y zero ) and (x_1, y_1)(x 1,y 1) representing two diagonally reverse corners. On this job, you have to decide whether or not some extent is situated inside such a rectangle or not.
Within the file uke_02_oppg_8.py, write a perform point_in_rectangle that has six parameters x0, y0, x1, y1, x2, y2, the place the primary 4 parameters characterize a hyperrectangle, and the final two characterize an arbitrary level. Let the tactic return True if the purpose is contained in the rectangle, and False if not. If the purpose is situated precisely on the road, we think about it to be inside.
You shouldn’t import any libraries to resolve this job.
Check your code:
Trace
• Recalculate the rectangle in order that you realize what is correct and left, prime and backside. For instance, the minimal of x0 and x1 would be the left-hand facet, whereas the utmost would be the right-hand facet. Correspondingly for prime and backside with the y-axis.
• Verify that the purpose is each between the left and proper sides, and likewise between prime and backside.
job 8b
Within the file uke_02_oppg_8.py, write a perform rectangles_overlap that has eight parameters x0, y0, x1, y1, x2, y2, x4, y4, the place the primary 4 parameters characterize one hyperrectangle, and the final 4 characterize one other. Let the tactic return True if the rectangles overlap, and False if not. We are saying that the rectangles overlap even when they solely share a single level.
You shouldn’t import any libraries to resolve this job.
Check your code:
Trace
Recalculate each rectangles so you realize what is correct and left, prime and backside.
If the best facet of 1 rectangle is to the left of the left facet of the opposite, the reply is fake (corresponding logic with prime and backside). Keep in mind to examine each instructions.
Illustration of the check instances above:
Job 8c
Within the file uke_02_oppg_8.py, write a perform circle_overlaps_rectangle that has seven parameters x0, y0, x1, y1, x2, y2, r2, the place the primary 4 parameters characterize a hyperrectangle, and the final three characterize a circle centered at (x_2, y_2 )(x 2,y 2) with radius r_2r 2
. Let the tactic return True if the circle overlaps the rectangle, and False if not. If the circle and the rectangle solely share a single level, they’re nonetheless thought of to be overlapping.
You shouldn’t import any libraries to resolve this job.
Check your code:
Trace
• If the middle of the circle is contained in the rectangle, the reply is True. Use the perform you wrote in 8a to examine this. You may name the perform, you need not rewrite the logic. For instance: if point_in_rectangle(…):.
• Convert the factors from x0 and x1 to left edge (minimal of x0 and x1) and proper edge (most). Equally, convert factors y0 and y1 to prime and backside.
• “Increase” the rectangle by the radius of the circle in all instructions. If the middle of the circle is exterior this prolonged rectangle (use the perform from 8a once more), there may be assured to be no overlap.
• Within the remaining instances, the middle of the circle is within the body across the rectangle (see determine above).
If the circle’s x-coordinate is between the x-coordinates of the unique rectangle, there may be an overlap.
Correspondingly for the y-axis.
If the middle of the circle doesn’t fulfill both of the 2 factors above, it’s situated in one of many corners. If the middle of the circle has a better distance than r_2r2
to all corners of the unique rectangle, there isn’t a overlap (e.g. as within the determine above). To search out the space finish, use the perform from lab1.
Illustration of the check instances acknowledged above (one circle per check case)

Order | Check Discount

Assignment Help For You!

Special Offer! Get 20-30% Off on Every Order!

Why Seek Our Custom Writing Services

Every Student Wants Quality and That’s What We Deliver

Graduate Essay Writers

Only the finest writers are selected to be a part of our team, with each possessing specialized knowledge in specific subjects and a background in academic writing..

Affordable Prices

We balance affordability with exceptional writing standards by offering student-friendly prices that are competitive and reasonable compared to other writing services.

100% Plagiarism-Free

We write all our papers from scratch thus 0% similarity index. We scan every final draft before submitting it to a customer.

How it works

When you opt to place an order with Nursing StudyBay, here is what happens:

Fill the Order Form

You will complete our order form, filling in all of the fields and giving us as much instructions detail as possible.

Assignment of Writer

We assess your order and pair it with a custom writer who possesses the specific qualifications for that subject. They then start the research/write from scratch.

Order in Progress and Delivery

You and the assigned writer have direct communication throughout the process. Upon receiving the final draft, you can either approve it or request revisions.

Giving us Feedback (and other options)

We seek to understand your experience. You can also peruse testimonials from other clients. From several options, you can select your preferred writer.

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00