Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the tool life counter to zero.
CNC Programming
tool_life_counter = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting the counter at 1 instead of 0.
Using None which is not a number.
✗ Incorrect
The tool life counter should start at zero to count the usage from the beginning.
2fill in blank
mediumComplete the code to increment the tool life counter by one after each use.
CNC Programming
tool_life_counter [1]= 1
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-=' which decreases the counter.
Using '*' or '/' which are not for incrementing.
✗ Incorrect
Incrementing by one uses the '+=' operator to add 1 to the current count.
3fill in blank
hardFix the error in the condition that checks if the tool life has reached its limit.
CNC Programming
if tool_life_counter [1] tool_life_limit:
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which only checks for exact equality.
Using '<' which checks the wrong direction.
✗ Incorrect
The tool should be replaced when the counter is greater than or equal to the limit.
4fill in blank
hardFill both blanks to reset the tool life counter and log the replacement.
CNC Programming
tool_life_counter [1] 0 log_message = 'Tool replaced at count ' + str([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' instead of '=' to reset the counter.
Logging the counter instead of the limit.
✗ Incorrect
Reset the counter to zero and log the limit value when the tool is replaced.
5fill in blank
hardFill both blanks to create a dictionary tracking tool usage and check if replacement is needed.
CNC Programming
tool_usage = {: {BLANK_2}} for {{BLANK_2}} in tool_list if tool_life_counter >= tool_life_limit Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using curly braces to create a dictionary.
Mixing up the variable names in the comprehension.
✗ Incorrect
Create a dictionary with keys as tools and values as the life limit, iterating over the tool list.