Challenge - 5 Problems
G-code Guru
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this G-code post-processor snippet?
Given this simplified post-processor script snippet that converts a move command into G-code, what is the exact output?
CNC Programming
def generate_gcode_move(x, y, z): return f"G01 X{x:.3f} Y{y:.3f} Z{z:.3f} F1000" print(generate_gcode_move(12.3456, 7.8910, 0))
Attempts:
2 left
💡 Hint
Look at how the numbers are formatted with three decimal places.
✗ Incorrect
The f-string formats the numbers to three decimal places, rounding the values accordingly. So 12.3456 becomes 12.346, 7.8910 becomes 7.891, and 0 becomes 0.000.
🧠 Conceptual
intermediate1:30remaining
Which statement best describes the role of a post-processor in CNC automation?
Choose the most accurate description of what a post-processor does in CNC programming.
Attempts:
2 left
💡 Hint
Think about what happens after a toolpath is created but before the machine runs.
✗ Incorrect
A post-processor translates the generic toolpath into the exact G-code commands that a specific CNC machine understands.
🔧 Debug
advanced1:30remaining
Identify the error in this post-processor code snippet
This Python snippet is intended to generate a G-code line for spindle speed setting. What error will it cause when run?
CNC Programming
def spindle_speed_command(speed): return f"S{speed} M03" print(spindle_speed_command('fast'))
Attempts:
2 left
💡 Hint
Check if the function accepts any string and what the output would be.
✗ Incorrect
The function simply inserts the speed string into the G-code line. It does not validate the speed value, so no error occurs and it outputs 'Sfast M03'.
🚀 Application
advanced1:30remaining
How many lines of G-code will this post-processor generate?
Given this post-processor code that generates G01 moves for a list of points, how many G-code lines will be printed?
CNC Programming
points = [(0,0,0), (10,0,0), (10,10,0), (0,10,0)] for pt in points: print(f"G01 X{pt[0]} Y{pt[1]} Z{pt[2]}")
Attempts:
2 left
💡 Hint
Count how many points are in the list and how many times the loop runs.
✗ Incorrect
The loop runs once for each point in the list, printing one G-code line per point. There are 4 points, so 4 lines are printed.
💻 Command Output
expert2:30remaining
What is the output of this complex post-processor snippet?
This snippet generates a G-code block with conditional feedrate. What is the exact output?
CNC Programming
def generate_gcode_block(x, y, z, feedrate=None): fr = f"F{feedrate}" if feedrate else "" return f"G01 X{x:.2f} Y{y:.2f} Z{z:.2f} {fr}".strip() print(generate_gcode_block(5, 5, 0, feedrate=1500))
Attempts:
2 left
💡 Hint
Check how the feedrate is added only if provided and how numbers are formatted.
✗ Incorrect
The feedrate is included as 'F1500' because feedrate is given. The coordinates are formatted to two decimals, so 5 becomes 5.00 and 0 becomes 0.00.