Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1)) The following function is supposed to compute and display the value of n-factorial for integers greater than 0. def factorial(n): result = 1 for

1))

The following function is supposed to compute and display the value of n-factorial for integers greater than 0.

def factorial(n): result = 1 for i in range(1, n + 1): result = result * i 

What is wrong with this function?

The indenting is wrong. All of the lines should be indented by the same amount.

The calculation is wrong. The result variable will have something other than n-factorial stored in it.

The function is missing a line. A print statement must be added at the end of it.

The function is missing a line. A return statement must be added at the end of it.

2)

image text in transcribed

3)

image text in transcribed

4)

image text in transcribed

5) The following function is supposed to compute the area of a triangle and return the area as the function's result.

def triangle_area(base, height): area = base * height / 2 ____________________ 

What line of code must be placed in the blank to achieve this goal?

print area
print(area)
return area
return triangleArea
Given the following code snippet, what is the value of the variable removed_value? states - ["Alaska", "Hawaii", "Florida" "Maine", "Ohio,"Florida" removed_value - states.pop(3) 0 3 Maine Florida Hawaii

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

Recognize the various roles and competencies of an HRD professional

Answered: 1 week ago