0
0
CNC Programmingscripting~15 mins

Surface finish standards (Ra) in CNC Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Surface Finish Standards (Ra) Calculator
📖 Scenario: You work in a CNC machining shop. You need to check if the surface finish of parts meets the required roughness average (Ra) standards. Ra is a number that shows how smooth a surface is. Lower Ra means smoother.Each part has a measured Ra value. You want to find which parts pass or fail based on a maximum allowed Ra.
🎯 Goal: Build a small Python script that stores Ra values for parts, sets a maximum allowed Ra, checks each part's Ra against the max, and shows which parts pass or fail.
📋 What You'll Learn
Create a dictionary called parts_ra with exact part names and Ra values
Create a variable called max_ra with the maximum allowed Ra value
Use a dictionary comprehension to create a new dictionary ra_results that stores 'Pass' or 'Fail' for each part based on max_ra
Print the ra_results dictionary to show the results
💡 Why This Matters
🌍 Real World
CNC machinists and quality inspectors use Ra values to ensure parts meet smoothness standards for function and appearance.
💼 Career
Knowing how to automate checking Ra values helps reduce manual errors and speeds up quality control in manufacturing.
Progress0 / 4 steps
1
Create the parts Ra dictionary
Create a dictionary called parts_ra with these exact entries: 'PartA': 1.2, 'PartB': 0.8, 'PartC': 1.5, 'PartD': 0.5
CNC Programming
Need a hint?

Use curly braces {} to create a dictionary with the exact part names and Ra values.

2
Set the maximum allowed Ra
Create a variable called max_ra and set it to the float value 1.0
CNC Programming
Need a hint?

Just write max_ra = 1.0 to set the maximum allowed Ra.

3
Create the pass/fail results dictionary
Use a dictionary comprehension to create a new dictionary called ra_results. For each part, ra in parts_ra.items(), set the value to 'Pass' if ra <= max_ra, otherwise 'Fail'
CNC Programming
Need a hint?

Use {part: ('Pass' if ra <= max_ra else 'Fail') for part, ra in parts_ra.items()} to build the dictionary.

4
Print the results
Write a print statement to display the ra_results dictionary
CNC Programming
Need a hint?

Use print(ra_results) to show the pass/fail results.