Syntax and values
Numbers, strings, booleans, variables, expressions, comments, and readable naming.
The programming foundation for artificial intelligence: data structures, control flow, functions, files, modules, and notebook practice.
Numbers, strings, booleans, variables, expressions, comments, and readable naming.
Lists, tuples, dictionaries, sets, indexing, slicing, iteration, and nested data.
Conditionals, loops, comparisons, truth values, and simple decision rules.
Parameters, return values, scope, reusable transformations, and small testable blocks.
Reading files, writing outputs, importing libraries, and organizing code into modules.
Run cells deliberately, inspect intermediate values, keep experiments reproducible, and explain each step.
Use a list of model-like scores, compare each value to a threshold, and create a label for each result.
0.85 and compare the labels.excellent for scores above 0.90.scores = [0.72, 0.81, 0.66, 0.90]
threshold = 0.75
labels = []
for score in scores:
if score >= threshold:
labels.append("ready")
else:
labels.append("review")
print(labels) AI code becomes easier to read when repeated decisions are moved into small functions with clear inputs and outputs.
label_score returns.def label_score(score, threshold=0.75):
if score >= threshold:
return "ready"
return "review"
scores = [0.72, 0.81, 0.66, 0.90]
labels = [label_score(score) for score in scores]
print(labels)