File tree 4 files changed +13
-6
lines changed
4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
# Calculate compound interest to track the growth of an investment
6
6
7
+
7
8
def invest (amount , rate , years ):
8
9
for year in range (1 , years + 1 ):
9
10
amount = amount * (1 + rate )
Original file line number Diff line number Diff line change 4
4
5
5
# Simulate the results of a series of coin tosses and track the results
6
6
7
- # This one is tricky to structure correctly. Try writing out the logic before you start coding. Some additional pointers if you're stuck:
7
+ # This one is tricky to structure correctly. Try writing out the logic before
8
+ # you start coding. Some additional pointers if you're stuck:
8
9
# 1. You will need to use a `for` loop over a range of trials.
9
10
# 2. For each trial, first you should check the outcome of the first flip.
10
11
# 3. Make sure you add the first flip to the total number of flips.
11
- # 4. After the first toss, you'll need another loop to keep flipping while you get the same result as the first flip.
12
+ # 4. After the first toss, you'll need another loop to keep flipping while you
13
+ # get the same result as the first flip.
12
14
13
15
from random import randint
14
16
Original file line number Diff line number Diff line change 4
4
5
5
# Simulate the results of a series of coin tosses and track the results
6
6
7
- # This one is tricky to structure correctly. Try writing out the logic before you start coding. Some additional pointers if you're stuck:
7
+ # This one is tricky to structure correctly. Try writing out the logic before
8
+ # you start coding. Some additional pointers if you're stuck:
8
9
# 1. You will need to use a `for` loop over a range of trials.
9
10
# 2. For each trial, first you should check the outcome of the first flip.
10
11
# 3. Make sure you add the first flip to the total number of flips.
11
- # 4. After the first toss, you'll need another loop to keep flipping while you get the same result as the first flip.
12
+ # 4. After the first toss, you'll need another loop to keep flipping while you
13
+ # get the same result as the first flip.
12
14
13
15
from random import randint
14
16
Original file line number Diff line number Diff line change 4
4
5
5
# Simulate the results of a series of coin tosses and track the results
6
6
7
- # This one is tricky to structure correctly. Try writing out the logic before you start coding. Some additional pointers if you're stuck:
7
+ # This one is tricky to structure correctly. Try writing out the logic before
8
+ # you start coding. Some additional pointers if you're stuck:
8
9
# 1. You will need to use a `for` loop over a range of trials.
9
10
# 2. For each trial, first you should check the outcome of the first flip.
10
11
# 3. Make sure you add the first flip to the total number of flips.
11
- # 4. After the first toss, you'll need another loop to keep flipping while you get the same result as the first flip.
12
+ # 4. After the first toss, you'll need another loop to keep flipping while you
13
+ # get the same result as the first flip.
12
14
13
15
from random import randint
14
16
You can’t perform that action at this time.
0 commit comments