Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python Please! Part 1: Come up with the most creative expression that evaluates to 2023, using only numbers and the [ +,, ] operators.

In Python Please!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Part 1: Come up with the most creative expression that evaluates to 2023, using only numbers and the [ +,, ] operators. You should replace the underscores in return with the expression that evaluates to 2023. Do not print the result. Sample Submission[DELETE THIS]: Part 2: Try to rewrite the same expression, this time entirely with call expressions (using function calls: add, mul, sub, etc... You can use from operators import add, mul, sub) Question 2: Area Part 1: Write definitions for these functions: sphereArea(radius) returns the surface area of a sphere having the given radius. sphere Volume (radius). Returns the volume of a sphere having the given radius. Write two test cases for each function. Be careful! These functions will return decimal numbers (floats). Part 2: Rewrite above functions with lambda expressions and assign them to respective names. You can just use a Python shell and take the screenshot of the code. Question 3: Rain or Shine Part 1: Alfonso will only wear a jacket outside if it is below 60 degrees or it is raining. Write a function that takes in the current temperature and a boolean value telling if it is raining and it should return True if Alfonso will wear a jacket and False otherwise. Try solving this problem with a single line of code. Note that it should either return True or False based on a single condition, whose truthiness value will also be either True or False. Part 2: Rewrite above function with a lambda expression. You can just use a Python shell and take the screenshot of the code. Question 4: Sum of the first N natural numbers: Part 1: Write a function sumNaturals (n) that returns the sum of the first n natural numbers. You can use this formula 1+2++n=n(n+1)/2. Make sure that the function returns an integer. Do not use a for loop or a while loop. Part 2: Define a lambda expression that takes n and returns the sum of the first n natural numbers, using the above formula. You can just use a Python shell and take the screenshot of the code. Question 5: You Define a Function Part 1: Write a function that takes in one or two input parameters and returns an output. The function should return the output of a one-line expression. Write at least three test cases for your function in the docstring. Use the command line to test your function against the test cases. Take a screenshot of your code and the result of your test. Also, write the function in the below box as well. Make sure your function has just one-line of code Part 2: Write the same function as a lambda function

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

Types of Interpersonal Relationships?

Answered: 1 week ago

Question

Self-Disclosure and Interpersonal Relationships?

Answered: 1 week ago