Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using python jupyter lap Q12. A regular polygon has n number of sides. Each side has length s. The area of a regular polygon is:

image text in transcribedimage text in transcribed

using python jupyter lap

Q12. A regular polygon has n number of sides. Each side has length s. The area of a regular polygon is: 0.25*n*s? tan(x) The perimeter of a polygon is: length of the boundary of the polygon Write a function called polysum that takes 2 arguments, n and s. This function should sum the area and square of the perimeter of the regular polygon. The function returns the sum, rounded to 4 decimal places. Hint: Which library should you be importing at the beginning of your code in order to call the tan function and to get the pi constant? Q13. Write a Python program that includes the following functions: I A) A function that finds the repeated items of a tuple. Sample tuple/Input: (2, 4, 5, 6, 2, 3, 4, 4, 7) Function returns: 3 B) A function that find the second largest number in a list. Sample List/Input: [1, 1, 1, 0, 0, 0, 2, -2, -2] Output: 1 Sample List/Input: [2,2] Output: None C) A function that removes duplicates from a list. Sample List/Input: [10,20,30,20,10,50,60, 40,80,50,40] Output: [40, 10, 80, 50, 20, 60, 30] D) A function that counts the number of elements in a list within a specified range. Sample List/Input: [10,20,30, 40, 40, 40,70,80,991, range= 40,100 Output: 6 Q14. Write a Python codes using NumPy that: A) Form the 2-D array (4 x 5), starting from 1 to 20 (without typing it in explicitly), and generate a new array containing its 2nd and 4th rows. B) Create an array of the first 10 odd integer. Then convert it to 2D array with 2 TOWS. C) Create a 4x3 array and compute: the sum of all the entries, the sum of the rows and the sum of the columns. D) Write a Python program to normalize a 3x3 random matrix Original Array: [[ 0.89372503 0.99865458 0.77120044] [ 0.67632984 0.99990084 0.64110391] [0.34845794 0.66557903 0.29031742]] After normalization: [[ 0.85036881 0.99824367 0.67769765] [ 0.54399864 1. 0.49435553] [ 0.08193614 0.52884777 0.]] E) Create a 2d array with 1 on the border and 0 inside

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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

What is meant by planning or define planning?

Answered: 1 week ago

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

Advance warning and an explanation for the layoff.

Answered: 1 week ago