In: Computer Science
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%!
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: