Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

UCSD Basic Python Worksheet

UCSD Basic Python Worksheet

UCSD Basic Python Worksheet

Description

In this exercise you will be defining several different functions

  1. For each function below, a) define the function, then b) evaluate and print out its return value to test that it gives the correct output. There are also some additional constraints:
    • All variable and parameter names should use snake_case for names with multiple words.
    • All print()ing should happen outside the functions.

Exercise Functions

  1. bool_to_int

    Define a lambda function and assign it to the bool_to_int variable. This function should have one parameter named value, which will receive a boolean argument. The function should convert that boolean argument to an integer and return it.

    Examples:
    bool_to_int(True) # returns 1
    bool_to_int(False) # returns 0
  2. get_smaller

    Define a lambda function and assign it to the get_smaller variable. This function should have two parameters named a and b, which will each receive a numeric argument. The function should return the smaller of those two arguments.

    Examples:
    get_smaller(16, 31) # returns 16
    get_smaller(253, 223) # returns 223
  3. cube

    Define a def function named cube. This function should have one parameter named base, which will receive a numeric argument. The function should return the value of the argument raised to the 3rd power. Call it with positional arguments only.

    Examples:
    cube(2) # returns 8
    cube(5) # returns 125
  4. absolute_difference

    Define a def function named absolute_difference. This function should have two parameters named a and b, which will each receive a numeric argument. The function should return the absolute value of the difference of the arguments. Call it with positional arguments only.

    Examples:
    absolute_difference(14, 11) # returns 3
    absolute_difference(13, 40) # returns 27
  5. squared_difference

    Define a def function named squared_difference. This function should have two parameters named a and b, which will each receive a numeric argument. The function should return the square of the difference of the arguments. Call it with positional arguments only.

    Examples:
    squared_difference(14, 11) # returns 9
    squared_difference(13, 40) # returns 729
  6. hours_to_minutes

    Define a def function named hours_to_minutes. This function should have one parameter named hours, which will receive a numeric argument. The function should return the number of minutes equal to argument’s number of hours. Call it with keyword arguments only.

    Examples:
    hours_to_minutes(hours = 3.5) # returns 210.0
    hours_to_minutes(hours = 12) # returns 720
  7. get_circumference

    Define a def function named get_circumference. This function should have one parameter named radius, which will receive a numeric argument. The function should return the circumference of a circle with that radius. Call it with keyword arguments only.

    Examples:
    get_circumference(radius = 1) # returns 6.283185307179586
    get_circumference(radius = 9.2) # returns 57.8053048260521912
  8. linear_transform

    Define a def function named linear_transform. This function should have three parameters named x, slope, and intercept; which will each receive a numeric argument. The function should return the vertical position of a straight line with slope slope and vertical-axis-intecept intercept at horizontal position x (in other words, it should evaluate a linear equation). Call it with keyword arguments only, and use a different argument order with each function call.

    Examples:
    linear_transform(x=5.0, slope=3.0, intercept=-8.5)
    # returns 6.5
    linear_transform(slope=-2.1, intercept=17.0, x=2.5)
    # returns 11.75
  9. standardize

    Define a def function named standardize. This function should have three parameters named x, x_center, and scale_size; which will each receive a numeric argument, and scale_size will always be positive. The function should return the difference between x and x_center, divided by the scale_size. Call it with keyword arguments only, and use a different argument order with each function call.

    Examples:
    standardize(x=8.2, x_center=13.8, scale_size=4.83)
    # returns -1.1594202898550727
    standardize(scale_size=24.63, x=2.89, x_center=-72.813)
    # returns 3.073609419407227

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20