Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is Python Questions using Jupyter Lab. Can anyone help me figuring out the codes to get those answers. Please use Jupyter Lab or Notebook

This is Python Questions using Jupyter Lab.

Can anyone help me figuring out the codes to get those answers.

Please use Jupyter Lab or Notebook as long as possible, and don't use built-in functions.

Thanks a lot.

(It would be grateful if you could paste the screenshot of the answers.)

1.

Write a function

double(arg)

that doubles the value of its argument, arg and returns the result.

ex. assert double(2.5) ==5.0

assert double("Hey, Booner") == "Hey, BoomerHey, Boomer"

2.

Q (Attributed to Havill in Intro textbook) The speeding ticket fine in a nearby town is $50 plus $5 for each mph over the posted speed limit. In addition, there is an extra penalty of $200 for all speeds above 90 mph. Write a function

fine(speedLimit, clockedSpeed)

that returns the fined amount (or 0 if clockedSpeed speedLimit).

assert fine(35, 40) == 75 assert fine(35, 35) == 0 assert fine(35, 36) == 55 assert fine(55, 89.875) == 224.375 assert fine(55, 90) == 225 assert fine(55, 91) == 430

3.

Q Write code to print a grid of 5 rows with 4 '*' characters in each row using nested for loops. This is a case where the solution cell is "capturing" what your code prints, so your solution must replace the comment and the raise exception at the same level of indentation. This allows the capture of the print and checking in the following cell to see if your solution is correct.

assert ( printed.getvalue() == '**** **** **** **** **** ' or printed.getvalue() == '**** **** **** **** ****' )

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_2

Step: 3

blur-text-image_3

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

Data Analytics And Quality Management Fundamental Tools

Authors: Joseph Nguyen

1st Edition

B0CNGG3Y2W, 979-8862833232

More Books

Students also viewed these Databases questions