Question: Exercises: 1. (1 point) Create a function that computes the surface area of a cylinder. The function must receive as inputs a radius r and


Exercises: 1. (1 point) Create a function that computes the surface area of a cylinder. The function must receive as inputs a radius r and a height h, and it must return the surface area. (Hint: Google "surface area of a cylinder"). 2. (1 point) What is the value of the variable decision in the following program? Show how you reached your answer. budget = 10000 cost = 1000 weight = 30 if (weight = 20) and (budget - cost > 500): decision = True else: decision = False 3. (1 point) What is the value of the expression int(3.4)? Evaluate the expression in Python. Note: this is a hint for the next problem. 4. (2 point) Create a function called round_up that receives as inpu positive number. The function rounds up the number to the highest half integer. For example: if the number is 3.1, the function must return 3.5; if the number is 3.6, the function must return 4; if the number is 4.5 the function must return 4.5. [Commentary: Note that this type of rounding is not unusual in engineering. Imagine that a design equation tells you that the minimum thickness of a design element is 5.4513 inches (e.g., the thickness of a road pavement). It is likely that for practical manufacturing or construction purposes you should round up to a particular level of precision (e.g., up to the nearest half inch.] 5. (1 point) Create a function called ticket_cost. This function computes the cost of a movie ticket. The base cost is $5, but the person will receive a discount if the person is a senior citizen ($2 discount) or a student ($1 discount). Make sure that the function asks the user if the person is a senior citizen or if the person is a student. The function must print the cost of the movie ticket based on the information provided. 6. (1 point) Machine Learning Application Logistic regression (LR) is a type of model used to compute the probability that a class or an event is observed. LR is commonly used in machine learning applications. In this problem, we will implement a logistic regression models and then we will apply it. a. A company is interested in determining the probability that a person will rent their e-scooters for a trip from Terrace to UPRM. They have a LR model that computes the probability that a person rents an e-scooter; we will use p to represent this probability. Create a function called Ir_model that implements the following LR model: p 1 1 + e-z where z = Bo + B1X1 + B2X2. The variable x1 represents a person's income and the variable x2 is the price of an e-scooter trip. The Bo, B1, B2, X1, and x2 variables must be represented as the function parameters. The function must return the value of p. b. The model classifies people as renters and non-renters of the company's e-scooters based on each person renting probability (p). The decision rule" is as follows: if the probability p is greater than 0.5, the person is classified as a renter; otherwise, the person is classified as a non-renter. Create a function called classification that implements the decision rule. The function must return the value of a variable called decision. decision is 1 if p is greater than 0.5 (i.e., the person is classified as a renter), and 0 otherwise (i.e., the person is classified as a non-renter). c. Add the Ir_model function and the classification function within function called demand forecast. This function predicts the level of demand for scooters at different price levels. Run the test case for this function. Include in your document the graphical output. The result should be similar to this graph: 10000 8000 6000 Demand (Number of renters) 4000 2000 0 0 4 5 2 3 Trip Prices
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
