Range Over Built in Latex

Here is the translation of the provided code to Python, following the provided structure and explanations:

We use a for loop to sum the numbers in a list. Arrays work like this too.

nums = [2, 3, 4]
sum = 0

for num in nums:
    sum += num
print("sum:", sum)

In Python, there is no range function with the same functionality as in the provided example. However, you can achieve the same result using for loops in lists.

for loop in Python provides both the index and value for each entry. Sometimes we want to use the indexes as well.

for i, num in enumerate(nums):
    if num == 3:
        print("index:", i)

for loop on dictionary iterates over key/value pairs.

kvs = {"a": "apple", "b": "banana"}
for k, v in kvs.items():
    print(f"{k} -> {v}")

for loop can also iterate over just the keys of a dictionary.

for k in kvs.keys():
    print("key:", k)

for loop on strings iterates over Unicode code points. The first value is the starting byte index of the character and the second the character itself.

for i, c in enumerate("go"):
    print(i, ord(c))

To run the program in Python, you just need to save it to a file and use Python to execute it.

$ python your_script.py
sum: 9
index: 1
a -> apple
b -> banana
key: a
key: b
0 103
1 111

This should cover the translation from the provided code example to Python following the original structure and explanations.