Through all the Python Basics lessons, we’ve provided lots of examples to demonstrate a useful subset of basic python. Below we outline a series of exercises you can try on your own to test what you’ve learned. We are not providing solutions, but we do link to the pages that provided the required background

1. Add a list of numbers from a file
For this first exercise, consider the following file
1,2
3,4
7,1
10,0
Write a program that reads in the file, and prints out the sum of each line, like follows:
3
7
8
10
Style points if you format it as follows
1 + 2 = 3
3 + 4 = 7
7 + 1 = 8
10 + 0 = 10
Hints: Python Hello World, Python Common Syntax Example and Files in Python
2. Store list of numbers in a list, then iterate though it once to add the numbers and once to multiply
For our second exercise, we start with the same list of numbers. Reading it in only once, we want to first add the numbers in each line, like before, but then we want to multiply them. The output should look like the following. The goal is to read the file just once though.
Adding:
3
7
8
10
Multiplying:
2
12
7
0
Again, style points for the following formatting
Adding:
1 + 2 = 3
3 + 4 = 7
7 + 1 = 8
10 + 0 = 10
Multiplying:
1 x 2 = 2
3 x 4 = 12
7 x 1 = 7
10 x 0 = 0
Hints: Exercise 1 + Python Simple Lists