Because floating-point numbers are imprecise, it is common to compute data values of type float that are very close but not exactly equal to the value 0.0.
a) In Python, Write a function countNZdata that counts number of elements in a list of type float whose absolute value is less than or equal to a positive tolerance parameter. The function takes the list as its first parameter; the second parameter is the positive float value that is the tolerance. Function should return the number of data values that meet this criterion.
For example, for the given list:
[2.19, -0.04, 1.66, 0.05, 4.70, -6.53, -0.11, -1.07, 1.94, -2.23]
and a tolerance = 0.1, the function should return the value 3.
b) Demonstrate that the function works by inputting different example values.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Write in C++ Sam is making a list of his favorite Pokemon. However, he changes his mind a lot. Help Sam write a function insertAfter() that takes five parameters and inserts the name of a Pokemon right after a specific index. Function specifications Name: insertAfter() Parameters (Your function should accept these parameters IN THIS ORDER): input_strings string: The array containing strings num_elements int: The number of elements that are currently stored in the array arr_size int: The number of elements that can be stored in the array index int: The location to insert a new string. Note that the new string should be inserted after this location. string_to_insert string: The new string to be inserted into the array Return Value: bool: true: If the string is successfully inserted into the array false: If the array is full If the index value exceeds the size of the arrayarrow_forwardIn C programming: Write a function printAllCourses() which receives an array of course pointers and the array’s size, then prints all courses in the array by calling printCourseRow()arrow_forwardUsing C++ Language In this program you will write a function of void return type named compare that accepts an integer parameter named guess. This function will compare the value of guess with a seeded randomly generated integer between 1 to 100, inclusive, and let the user know what the random number was as well as whether the guess was larger than, smaller than or equal to the random number. NOTE THAT: You will NOT generate a random number inside the compare function. Rather, you will write another function named getRandom of int return type to do it. You will need to call getRandom from compare, no parameters are necessary. Inside your main function, get the guess from user and pass it to the compare function. Code: #include <iostream>using namespace std; int getRandom(){ //generate seeded random num. //in between 1-100 inclusive //return random number } void compare(int guess){ //call getRandom //compare guess with random number //inform user what…arrow_forward
- python only define the following function: This function must reset the value of every task in a checklist to False. It accept just one parameter: the checklist object to reset, and it must return the (now modified) checklist object that it was given. Define resetChecklist with 1 parameter Use def to define resetChecklist with 1 parameter Use a return statement Within the definition of resetChecklist with 1 parameter, use return _in at least one place. Use any kind of loop Within the definition of resetChecklist with 1 parameter, use any kind of loop in at least one place.arrow_forwardThe programming language is - Python a. Write a function called daysOver that takes three arguments: a dictionary, a location (such as ‘Sydney’, ‘Adelaide’,etc) and a temperature and returns the number of days that were over the given temperature for the given location. For example, if we call the function using the line: total = daysOver(dictionaryData, ‘Adelaide’, 40) total will hold the number of days that Adelaide had a temperature greater than 40 celsius in the data. As a test, there were 54 days over 40 celsius in the data. Check that total is 54 for the example when you run your code. b. Use the daysOver function to print the number of days over 35 celsius for each of the following cities: 'Adelaide','Perth','Melbourne','Canberra','Sydney','Brisbane','Darwin' c. Which of the Australian cities has the most number of days over 35 celsius? My spreadsheet looks like this Since I cannot attach an excel file, my excel file name is "weatherAUS.csv"arrow_forwardA series of commands can be used to display a function's return address. Remember that any changes you make to the stack cannot prevent the procedure from returning to its caller.arrow_forward
- code in c programarrow_forwardLanguage: C Write the function convolve that will calculate the confolution of two functions f, g on [0, t] interval. The convolution is defined as (f ∗ g)(t) = Z t 0 f(τ )g(t − τ ) dτ for f, g : [0, ∞) → R. The argument function f and g should be passed by pointers. The integral should be approximated by the Riemman sum, i.e., Z b a f(x) dx = Xn i=1 f(xi) ∆x, where ∆x = b−a n and xi = a + i ∆x. Define the functions func1, func2 and func3, that return sin(x), cos(x) and x 3 respectively. Use these functions to calculate the convolution of f = sin(x), g = sin(x) f = sin(x), g = cos(x) f = sin(x), g = x 3 for t = 2π and n = 1000.arrow_forwardin python create function that has a parameter of dict[str, str] key should be a name value should be a word when given a dict of names and word, function should return the word that is most common ******************************* no using key, value for loops no .get, .items, .defaultset no importing builtins no using .values, .keys, or .index must do it through dictionary cycling ************************** should return a stringarrow_forward
- Using C++ Language Write a function call with arguments tensPlace, onesPlace, and userInt. Be sure to pass the first two arguments as pointers. Sample output for the given program: tensPlace = 4, onesPlace = 1 Code: #include <stdio.h> void SplitIntoTensOnes(int* tensDigit, int* onesDigit, int DecVal){ *tensDigit = (DecVal / 10) % 10; *onesDigit = DecVal % 10;} int main(void) { int tensPlace; int onesPlace; int userInt; scanf("%d", &userInt); /* Your solution goes here */ printf("tensPlace = %d, onesPlace = %d\n", tensPlace, onesPlace); return 0;}arrow_forwardlanguage = pythonarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education