Question

In: Computer Science

Python. The array C has multibel peaks (+ , -). write a code that detect the...

Python.

The array C has multibel peaks (+ , -). write a code that detect the vlaues of all those peaks.
C = [0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.0011
-0.0031
0.0011
0.0034
-0.0039
0.0004
0.0052
-0.0045
-0.0025
0.0067
-0.0038
-0.0034
0.0077
-0.0034
-0.0054
0.0076
-0.0011
-0.0063
0.0068
0.0004
-0.0084
0.0061
0.0037
-0.0086
0.0018
0.0063
-0.0045
-0.0069
0.0078
0.0027
-0.0132
0.0054
0.0133
-0.0131
-0.0060
0.0180
-0.0037
-0.0169
0.0140
0.0128
-0.0210
0.0048
0.0218
-0.0158
-0.0134
0.0216
-0.0004
-0.0205
0.0121
0.0126
-0.0197
-0.0031
0.0186
-0.0130
-0.0115
0.0160
-0.0010
-0.0114
0.0091
0.0026
-0.0087
0.0035
0.0043
-0.0047
0.0002
0.0025
-0.0015
-0.0006
0.0011
0.0002
-0.0006
-0.0004
0.0008
-0.0002
0
0
0
0
0
0
0
0
0
0
0]

Solutions

Expert Solution

C = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-0.0031, 0.0011, 0.0034, -0.0039, 0.0004, 0.0052,
     -0.0045, -0.0025, 0.0067, -0.0038, -0.0034, 0.0077, -0.0034, -0.0054, 0.0076, -0.0011,
     -0.0063, 0.0068, 0.0004, -0.0084, 0.0061, 0.0037, -0.0086, 0.0018, 0.0063, -0.0045,
     -0.0069, 0.0078, 0.0027, -0.0132, 0.0054, 0.0133, -0.0131, -0.0060, 0.0180, -0.0037,
     -0.0169, 0.0140, 0.0128, -0.0210, 0.0048, 0.0218, -0.0158, -0.0134, 0.0216, -0.0004,
     -0.0205, 0.0121, 0.0126, -0.0197, -0.0031, 0.0186, -0.0130, -0.0115, 0.0160, -0.0010,
     -0.0114, 0.0091, 0.0026, -0.0087, 0.0035, 0.0043, -0.0047, 0.0002, 0.0025, -0.0015,
     -0.0006, 0.0011, 0.0002, -0.0006, -0.0004, 0.0008, -0.0002, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0]
print("Data we have: ")
print(C)
print("\n")
min = 0
max = 0
for i in C:
    if i>max:        #If current value is greater than positive peak
        max = i      #current value is the new peak
    if i<min:        #if current value is less than negative peak
        min = i      #curernt value is the new peak

print("Positive peak: ")
print(max)
print("Negative paeak: ")
print(min)
sum = 0
for i in C:
    if i==max or i==min:
        sum += abs(i)

print("Final sum: ", end="")
print(sum)


Related Solutions

Write a code using c# Maximum Sub Array.
Write a code using c# Maximum Sub Array.
Write a code in c++ using dynamic array of structure and dynamic array list. Make a...
Write a code in c++ using dynamic array of structure and dynamic array list. Make a dummy list for a company which stores following information about its customers. Customer ID Customer Name Gender Total items purchased Item category 20% discount in percentage of total purchase amount. Use dynamic array to save at least 20 items by dividing them into 3 different categories. Make a dummy list of items that company sells by dividing them into two categorizes. Items has following...
Using c++ to find all the peaks elements in a 2d array, each element has eight...
Using c++ to find all the peaks elements in a 2d array, each element has eight neighbours
For these of string functions, write the code for it in C++ or Python (without using...
For these of string functions, write the code for it in C++ or Python (without using any of thatlanguage's built-in functions) You may assume there is a function to convert Small string into the language string type and a function to convert your language's string type back to Small string type. 1. int [] searchA,ll(string in...str, string sub): returns an array of positions of sub in in...str or an one element array with -1 if sub doesn't exist in in...str
C++ Write the code to implement a complete binary heap using an array ( Not a...
C++ Write the code to implement a complete binary heap using an array ( Not a vector ). Code for Max heap. Implement: AddElement, GetMax, HeapSort, ShuffleUp, ShuffleDown, etc Set array size to 31 possible integers. Add 15 elements 1,3,27,22,18,4,11,26,42,19,6,2,15,16,13 Have a default constructor that initializes the array to zeros.. The data in the heap will be double datatype. PART 2 Convert to the program to a template, test with integers, double and char please provide screenshots thank you so...
How do I write a C# and a C++ code for creating a character array containing...
How do I write a C# and a C++ code for creating a character array containing the characters 'p', 'i', 'n','e','P','I','N','E' only and then using these lower and capital case letter character generate all possible combinations like PInE or PinE or PIne or PINE or piNE etc. and only in this order so if this order is created eg. NeIP or EnPi or NeIP or IPnE and on. You can generate all the combinations randomly by creating the word pine...
Write in C Language Write all these code in one program and upload. Consider this array...
Write in C Language Write all these code in one program and upload. Consider this array char address1 [ ] = "12330 Washington Blvd, suite 300, Sacramento, CA 94560-2341" ; (NOTE: The constant string on the RHS gets copied into the array address1 on the LHS) 1. Write a piece of code to count only letters in the string address1 using the function isAlpha   2. Convert to all Upper Case Write a program to convert address1 to all uppercase letters...
a) Write C code initialize an array of ints to the last four digits of your...
a) Write C code initialize an array of ints to the last four digits of your phone number. Use a loop to add the digits. Calculate and display the average of the digits. b) Write C code using a struct to hold student information: integer id integer number of hours taken integer number of hours passed double gpa
For c++ Write the code to initialize an array such that each element gets two times...
For c++ Write the code to initialize an array such that each element gets two times the value of its index (e.g. 0, 2, 4, 6, …)
Write a Python function that accepts three arguments: an array, the size of the array, and...
Write a Python function that accepts three arguments: an array, the size of the array, and a number n. Assume that array contains integers. The function should display all integers in the array that are greater than the number n. Test your function.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT