Question

In: Computer Science

This basic problem is a practical application of if-statement(s). Write a function called bolt_check that takes...

This basic problem is a practical application of if-statement(s).

Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

This basic problem is a practical application of if-statement(s).

Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

This basic problem is a practical application of if-statement(s).

Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

This basic problem is a practical application of if-statement(s).

Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

This basic problem is a practical application of if-statement(s).

Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

This basic problem is a practical application of if-statement(s).

Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

This basic problem is a practical application of if-statement(s).

Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

This basic problem is a practical application of if-statement(s).

In matLab: Write a function called bolt_check that takes one scalar input argument and returns one scalar output argument. The input represents the measured length of a machine screw during the quality-assurance phase of its manufacturing. The purpose of the function is to categorize the measured length into one of six categories. If the measured length is within two percent of one of its five nominal lengths-- 3/8, 1/2, 5/8, 3/4, or 1 (inch), then the nominal length is returned. Otherwise 0 is returned, signifying that the bolt failed the test. You may find that the built-in function abs for absolute value is useful for this problem.

You may submit your work as many times as you want. Try to get 100%!

Solutions

Expert Solution

Please find the python program to return the nominal length of the measured length.

Program:

#percent definition, change as per requirement
PERCENT=2/100
#function definition
def bolt_check(measured_length):
  
if 3/8 * PERCENT >= measured_length:
return 3/8
elif 1/2 * PERCENT >= measured_length:
return 1/2
elif 5/8 * PERCENT >= measured_length:
return 5/8
elif 3/4 * PERCENT >= measured_length:
return 3/4
elif 1 * PERCENT >= measured_length:
return 1
else:
print("measured length not matches with in the 2% of nominal lengths.")
return 0

#read user input
inp=float(input("Enter the measured length: "))
ret=bolt_check(inp)
#print the message
if ret != 0
print("Nominal length for the measured length of %f is %f" %(0.02, ret))
else:
print("Enter measured length with in the range.")

  

Output:

Enter the measured length: 0.02
Nominal length for the measured length of 0.020000 is 1.000000

Screen Shot:


Related Solutions

Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of...
Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of the parameter le This function should return a dictionary that stores all of the parameter le data of the SIR model in a format that we will describe further below.
Programming in C (not C++) Write the function definition for a function called CompareNum that takes...
Programming in C (not C++) Write the function definition for a function called CompareNum that takes one doyble argument called "num". The function will declare, ask, and get another double from the user. Compare the double entered by the user to "num" and return a 0 if they are the same, a -1 num is less than the double entered by the user and 1 if it is greater.
Write a function called swapElements to swap two elements in a character array. This function takes...
Write a function called swapElements to swap two elements in a character array. This function takes two parameters, a character array and input file. The function should read two numbers from a file and it swap the elements stored in the indices read. please code in c++
A. Write a function in MATLAB called findTranspose that takes in as input any matrix or...
A. Write a function in MATLAB called findTranspose that takes in as input any matrix or any vector and simply returns back the transpose of that input. You can always verify your answer by using the inbuilt transpose function in MATLAB, however, you cannot use the transpose function directly when writing your code. Here is the starter code that we are providing to help you get started %x is the input vector or matrix. You can find the %size that...
C++ Write a function called linearSearch that takes an array as a parameter and search for...
C++ Write a function called linearSearch that takes an array as a parameter and search for a specific value inside this parameter. The function returns the frequency of a specific value in the array. In the main function: 1. Define an array called salaries of length 5. 2. Initialize the array by asking the user to input the values of its elements. 3. Define a variable called key and ask the user to enter a value for this variable. 4....
JavaScript Write a function called "first" that takes in two arguments - the first is an...
JavaScript Write a function called "first" that takes in two arguments - the first is an argument called arr that is an array of numbers, the second is an optional number argument called num(hint: you'll need a default value - look back at the slides). If "num" was not passed in (since it's optional), the "first" function will return an array containing the first item of the array. If a value for "num" was given, the "first" function will return...
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and...
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and returns a new sequence that is twice the length of the parameter sequence but that contains the contents of the original in palindrome form. For example, if the sequence "super" is passed into the function, the function will return "superrepus".
write an algorithm function called balance() in javascript that takes in a string and returns a...
write an algorithm function called balance() in javascript that takes in a string and returns a strinf with balanced parantheses only. the string should be able to contain only parantheses, numbers, and letters. include comments of each portion of your code balance(“()()”) should return “()()” balance(“())”) should return “()” balance(“a(b)c”) should return “a(b)c” balance(“a(b)c())”) should return “a(b)c()”
In C++ Write a function called findBestSimScore that takes a genome and a sequence and returns...
In C++ Write a function called findBestSimScore that takes a genome and a sequence and returns the highest similarity score found in the genome as a double. Note: the term genome refers to the string that represents the complete set of genes in an organism, and sequence to refer to some substring or sub-sequence in the genome. Your function MUST be named findBestSimScore Your function should take two parameters in this order: a string parameter for the genome (complete set...
Write a function, namely shape(s) that takes a positive integer s as the parameter and draws...
Write a function, namely shape(s) that takes a positive integer s as the parameter and draws a square of length s. The square should be filled by a randomized color. Then write another function, that calls the shape function to draw 4 squares as a 2x2 table. Please answer in python.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT