jack
2015-11-15 15:37:31 UTC
Hi Margot. Please come to my party on Saturday!
Hi Kathryn. Please come to my party on Saturday!
Hi Pamela. Please come to my party on Saturday!
2-Create two lists: list1 = [2, 6, 10] and list2 = [1, 3, 5]. Create a for loop that iterates through the two lists and calculates the difference between the respective element of each list. Also in the for loop, find the difference squared and keep a running total of that number.
Print the difference after each time it is calculated and the sum after each time it is calculated, so that it looks like this:
The difference is xxx
The sum is yyy
where xxx and yyy are the calculated values.
3-Write a program that generates all odd numbers from 1 to n. Ask the user for n and set n in the beginning of the program. Use a while loop to compute the numbers and create a list that contains the numbers. The print out the resulting list.