<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 last lesson we wrote code to plot some values from our inflammation data.
but we have a dozen we want to do same for
how to repeat things?
Step1:  This is a bad appoach b/c
Step2:  uses a for loop to repeat operations  
general form
Step3:  Let's trace the execution
Step4:  finding the length of a string is such a common operation that Python actually has a built-in function to do it called len
Step5:  for loop is a way to do operations many times, a list is a way to store many values
lists are builtins
use []
Loop challenge
Step6:  Loop challenge 2
Step7:  Loop challenge 3
<ASSISTANT_TASK:>
Python Code:
#example task: print each character in a word
#one way to do is use a series of print statements
word = 'lead'
print(word[0])
print(word[1])
print(word[2])
print(word[3])
Explanation: last lesson we wrote code to plot some values from our inflammation data.
but we have a dozen we want to do same for
how to repeat things?
End of explanation
word = 'tin'
print(word[0])
print(word[1])
print(word[2])
print(word[3])
#better approach
word = 'lead'
for char in word:
    print (char)
    
#better
word = 'supercalifragilisticexpialidocious'
for char in word:
    print (char)
    
Explanation: This is a bad appoach b/c:
doesnt scale - what if you wanted to print: supercalifragilisticexpialidocious - on for each 34 characters
fragile - long word it only prints partial; short sting it will throw error
End of explanation
length = 0
for vowel in 'aeiou':
    length = length + 1
    #print(vowel, length)
print('There are', length, 'vowels')
Explanation: uses a for loop to repeat operations  
general form: 
python
for variable in collection:
    do things with variable
loop variable can be arbitrary, need colon at the end
indention necessary
no command to end loop like many languages
End of explanation
#note loop var still exists after loop
letter = 'z'
for letter in 'abc':
    print(letter)
print('after the loop, letter is', letter)
Explanation: Let's trace the execution:
1. length is 1, vowel is 'a'
2. length is 2, vowel is 'e'
3. length is 3, vowel is 'i'
4. length is 4, vowel is 'o'
5. length is 5, vowel is 'u'
End of explanation
print(len('aeiou'))
Explanation: finding the length of a string is such a common operation that Python actually has a built-in function to do it called len:
End of explanation
# solution
for i in range(1, 4):
   print(i)
Explanation: for loop is a way to do operations many times, a list is a way to store many values
lists are builtins
use []
Loop challenge:
Python has a built-in function called range that creates a sequence of numbers. Range can accept 1-3 parameters. If one parameter is input, range creates an array of that length, starting at zero and incrementing by 1. If 2 parameters are input, range starts at the first and ends at the second, incrementing by one. If range is passed 3 parameters, it starts at the first one, ends at the second one, and increments by the third one. For example, range(3) produces the numbers 0, 1, 2, while range(2, 5) produces 2, 3, 4, and range(3, 10, 3) produces 3, 6, 9. Using range, write a loop that uses range to print the first 3 natural numbers:
1
2
3
End of explanation
result = 1
for i in range(0, 3):
   result = result * 5
print(result)
for i in range(0,3):
    print(i)
Explanation: Loop challenge 2:
Exponentiation is built into Python:
python
print(5 ** 3)
125
Write a loop that calculates the same result as 5 ** 3 using multiplication (and without exponentiation).
End of explanation
newstring = ''
oldstring = 'Newton'
length_old = len(oldstring)
for char_index in range(length_old):
   newstring = newstring + oldstring[length_old - char_index - 1]
print(newstring)
Explanation: Loop challenge 3:
Write a loop that takes a string, and produces a new string with the characters in reverse order, so 'Newton' becomes 'notweN'.
End of explanation
<END_TASK>