Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

1def calculate_stats(numbers):
2 """Calculate basic statistics"""
3 if not numbers:
4 return None
5
6 total = 0
7 count = 0
8 for num in numbers:
9 total += num
10 count += 1
11
12 average = total / count
13
14 # Find max and min
15 max_val = numbers[0]
16 min_val = numbers[0]
17 for num in numbers:
18 if num > max_val:
19 max_val = num
20 if num < min_val:
21 min_val = num
22
23 return {
24 'average': average,
25 'max': max_val,
26 'min': min_val,
27 'count': count
28 }

After

1def calculate_stats(numbers):
2 """Calculate basic statistics"""
3 if not numbers:
4 return None
5
6 # Use built-in functions for cleaner code
7 total = sum(numbers)
8 count = len(numbers)
9 average = total / count
10 max_val = max(numbers)
11 min_val = min(numbers)
12
13 return {
14 'average': average,
15 'max': max_val,
16 'min': min_val,
17 'count': count,
18 'total': total # Added total to returned stats
19 }

Before

module
function_definition
def "def"
identifier "calculate_stats"
parameters
( "("
identifier "numbers"
) ")"
: ":"
block
expression_statement
string
string_start "\"\"\""
string_content "Calculate basic statistics"
string_end "\"\"\""
if_statement
if "if"
not_operator
not "not"
identifier "numbers"
: ":"
block
return_statement
return "return"
none "None"
expression_statement
assignment
identifier "total"
= "="
integer "0"
expression_statement
assignment
identifier "count"
= "="
integer "0"
for_statement
for "for"
identifier "num"
in "in"
identifier "numbers"
: ":"
block
expression_statement
augmented_assignment
identifier "total"
+= "+="
identifier "num"
expression_statement
augmented_assignment
identifier "count"
+= "+="
integer "1"
expression_statement
assignment
identifier "average"
= "="
binary_operator
identifier "total"
/ "/"
identifier "count"
comment "# Find max and min"
expression_statement
assignment
identifier "max_val"
= "="
subscript
identifier "numbers"
[ "["
integer "0"
] "]"
expression_statement
assignment
identifier "min_val"
= "="
subscript
identifier "numbers"
[ "["
integer "0"
] "]"
for_statement
for "for"
identifier "num"
in "in"
identifier "numbers"
: ":"
block
if_statement
if "if"
comparison_operator
identifier "num"
> ">"
identifier "max_val"
: ":"
block
expression_statement
assignment
identifier "max_val"
= "="
identifier "num"
if_statement
if "if"
comparison_operator
identifier "num"
< "<"
identifier "min_val"
: ":"
block
expression_statement
assignment
identifier "min_val"
= "="
identifier "num"
return_statement
return "return"
dictionary
{ "{"
pair
string
string_start "'"
string_content "average"
string_end "'"
: ":"
identifier "average"
, ","
pair
string
string_start "'"
string_content "max"
string_end "'"
: ":"
identifier "max_val"
, ","
pair
string
string_start "'"
string_content "min"
string_end "'"
: ":"
identifier "min_val"
, ","
pair
string
string_start "'"
string_content "count"
string_end "'"
: ":"
identifier "count"
} "}"

After

module
function_definition
def "def"
identifier "calculate_stats"
parameters
( "("
identifier "numbers"
) ")"
: ":"
block
expression_statement
string
string_start "\"\"\""
string_content "Calculate basic statistics"
string_end "\"\"\""
if_statement
if "if"
not_operator
not "not"
identifier "numbers"
: ":"
block
return_statement
return "return"
none "None"
comment "# Use built-in functions for cleaner code"
expression_statement
assignment
identifier "total"
= "="
call
identifier "sum"
argument_list
( "("
identifier "numbers"
) ")"
expression_statement
assignment
identifier "count"
= "="
call
identifier "len"
argument_list
( "("
identifier "numbers"
) ")"
expression_statement
assignment
identifier "average"
= "="
binary_operator
identifier "total"
/ "/"
identifier "count"
expression_statement
assignment
identifier "max_val"
= "="
call
identifier "max"
argument_list
( "("
identifier "numbers"
) ")"
expression_statement
assignment
identifier "min_val"
= "="
call
identifier "min"
argument_list
( "("
identifier "numbers"
) ")"
return_statement
return "return"
dictionary
{ "{"
pair
string
string_start "'"
string_content "average"
string_end "'"
: ":"
identifier "average"
, ","
pair
string
string_start "'"
string_content "max"
string_end "'"
: ":"
identifier "max_val"
, ","
pair
string
string_start "'"
string_content "min"
string_end "'"
: ":"
identifier "min_val"
, ","
pair
string
string_start "'"
string_content "count"
string_end "'"
: ":"
identifier "count"
, ","
pair
string
string_start "'"
string_content "total"
string_end "'"
: ":"
identifier "total"
comment "# Added total to returned stats"
} "}"