<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Control Structures
Simple for loop
Write a for loop which iterates over the list of breakfast items "sausage", "eggs", "bacon" and "spam" and prints out the name of item
Step1:  Write then a for which loop determines the squares of the odd
integers up to 10. Use the range() function.
Step2:  Looping through a dictionary
Write a loop that prints out the names of the fruits in the dictionary containing the fruit prices.
Step3:  Next, write a loop that sums up the prices.
Step4:  While loop
Fibonacci numbers are a sequence of integers defined by the recurrence relation
F[n] = F[n-1] + F[n-2]
with the initial values F[0]=0, F[1]=1. 
Create a list of Fibonacci numbers F[n] < 100 using a while loop.
Step5:  If - else
Write a control structure which checks whether an integer is
negative, zero, or belongs to the prime numbers 3,5,7,11,17
and perform e.g. corresponding print statement.
Use keyword in when checking for belonging to prime numbers.
Step6:  Advanced exercises
Don't worry if you don't have time to finish all of these. They are not essential.
Looping through multidimensional lists
Start from a two dimensional list of (x,y) value pairs, and sort it according to y values. (Hint
Step7:  Next, create a new list containing only the sorted y values.
Step8:  Finally, create a new list consisting of sums the (x,y) pairs where both x and y are positive.
Step9:  List comprehension is often convenient in this kind of situations
Step10:  FizzBuzz
This is a classic job interview question. Depending on the interviewer or interviewee it can filter out up to 95% of the interviewees for a position. The task is not difficult but it's easy to make simple mistakes.
If a number is divisible by 3, instead of the number print "Fizz", if a number is divisible by 5, print "Buzz" and if the number is divisible by both 3 and 5, print "FizzBuzz".
Step11:  Food for thought
Step12:  List comprehension
Using a list comprehension create a new list, temperatures_kelvin from following Celsius temperatures and convert them by adding the value 273.15 to each.
<ASSISTANT_TASK:>
Python Code:
breakfast = ["sausage", "eggs", "bacon", "spam"]
for item in breakfast:
    print(item)
Explanation: Control Structures
Simple for loop
Write a for loop which iterates over the list of breakfast items "sausage", "eggs", "bacon" and "spam" and prints out the name of item
End of explanation
squares = []
for i in range(1, 10, 2):
    squares.append(i**2)
print(squares)
Explanation: Write then a for which loop determines the squares of the odd
integers up to 10. Use the range() function.
End of explanation
fruits = {'banana' : 5, 'strawberry' : 7, 'pineapple' : 3}
for fruit in fruits:
    print(fruit)
Explanation: Looping through a dictionary
Write a loop that prints out the names of the fruits in the dictionary containing the fruit prices.
End of explanation
sum = 0
for price in fruits.values():
    sum += price
print(sum)
Explanation: Next, write a loop that sums up the prices.
End of explanation
f = [0, 1]
while True:
    new = f[-1] + f[-2]
    if new > 100:
        break
    f.append(new)
print(f)
Explanation: While loop
Fibonacci numbers are a sequence of integers defined by the recurrence relation
F[n] = F[n-1] + F[n-2]
with the initial values F[0]=0, F[1]=1. 
Create a list of Fibonacci numbers F[n] < 100 using a while loop.
End of explanation
number = 7
if number < 0:
    print("Negative")
elif number == 0:
    print("Zero")
elif number in [3, 5, 7, 11, 17]:
    print("Prime")
Explanation: If - else
Write a control structure which checks whether an integer is
negative, zero, or belongs to the prime numbers 3,5,7,11,17
and perform e.g. corresponding print statement.
Use keyword in when checking for belonging to prime numbers.
End of explanation
xys =  [[2, 3], [0, -1], [4, -2], [1, 6]]
tmp = []
for x, y in xys:
    tmp.append([y,x])
tmp.sort()
for i, (y,x) in enumerate(tmp):
    xys[i] = [x,y]
print(xys)
Explanation: Advanced exercises
Don't worry if you don't have time to finish all of these. They are not essential.
Looping through multidimensional lists
Start from a two dimensional list of (x,y) value pairs, and sort it according to y values. (Hint: you may need to create a temporary list).
End of explanation
ys = []
for x, y in xys:
    ys.append(y)
print(ys)
Explanation: Next, create a new list containing only the sorted y values.
End of explanation
sums = []
for x, y in xys:
    if x > 0 and y > 0:
        sums.append(x + y)
print(sums)
Explanation: Finally, create a new list consisting of sums the (x,y) pairs where both x and y are positive.
End of explanation
xys = [[2, 3], [0, -1], [4, -2], [1, 6]]
tmp = [[y, x] for x, y in xys]
tmp.sort()
xys = [[x, y] for y, x in tmp]
# One liner is possible but not very readable anymore:
xys = [[x, y] for y, x in sorted([[ytmp, xtmp] for xtmp, ytmp in xys])]
# Summing positives with one liner is ok:
sums = [x+y for x,y in xys if x > 0 and y > 0]
Explanation: List comprehension is often convenient in this kind of situations:
End of explanation
for number in range(1, 101):
    if number % 3 == 0 and number % 5 == 0:
        print("FizzBuzz")
    elif number % 3 == 0:
        print("Fizz")
    elif number % 5 == 0:
        print("Buzz")
    print(number)
Explanation: FizzBuzz
This is a classic job interview question. Depending on the interviewer or interviewee it can filter out up to 95% of the interviewees for a position. The task is not difficult but it's easy to make simple mistakes.
If a number is divisible by 3, instead of the number print "Fizz", if a number is divisible by 5, print "Buzz" and if the number is divisible by both 3 and 5, print "FizzBuzz".
End of explanation
import random
while True:
    value = random.random() 
    if value < 0.1:
        break
print("done")
Explanation: Food for thought: How do people commonly fail this test and why?
Breaking
The python random module generates pseudorandom numbers.
Write a while loop that runs until 
the output of random.random() is below 0.1 and break when 
the value is below 0.1.
End of explanation
temperatures_celsius = [0, -15, 20.15, 13.3, -5.2]
temperatures_kelvin = [c+273.15 for c in temperatures_celsius]
Explanation: List comprehension
Using a list comprehension create a new list, temperatures_kelvin from following Celsius temperatures and convert them by adding the value 273.15 to each.
End of explanation
<END_TASK>