Skip to content

Commit 44982b7

Browse files
authored
Update 1_expenses.py
1 parent 7d353b8 commit 44982b7

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed
Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
1-
# 1. Let us say your expense for every month are listed below,
2-
# 1. January - 2200
3-
# 2. February - 2350
4-
# 3. March - 2600
5-
# 4. April - 2130
6-
# 5. May - 2190
7-
#
8-
# Create a list to store these monthly expenses and using that find out,
9-
#
10-
# 1. In Feb, how many dollars you spent extra compare to January?
11-
# 2. Find out your total expense in first quarter (first three months) of the year.
12-
# 3. Find out if you spent exactly 2000 dollars in any month
13-
# 4. June month just finished and your expense is 1980 dollar. Add this item to our monthly expense list
14-
# 5. You returned an item that you bought in a month of April and
15-
# got a refund of 200$. Make a correction to your monthly expense list
16-
# based on this
1+
arr = [2200,2350,2600,2130,2190]
172

18-
exp = [2200,2350,2600,2130,2190]
3+
# January - 2200
4+
# February - 2350
5+
# March - 2600
6+
# April - 2130
7+
# May - 2190
198

209
# 1. In Feb, how many dollars you spent extra compare to January?
21-
print("In feb this much extra was spent compared to jan:",exp[1]-exp[0]) # 150
10+
print(arr[1]-arr[0])
2211

23-
# 2. Find out your total expense in first quarter (first three months) of the year
24-
print("Expense for first quarter:",exp[0]+exp[1]+exp[2]) # 7150
12+
# 2. Find out your total expense in first quarter (first three months) of the year.
13+
print(arr[0]+arr[1]+arr[2])
2514

2615
# 3. Find out if you spent exactly 2000 dollars in any month
27-
print("Did I spent 2000$ in any month? ", 2000 in exp) # False
16+
17+
print(2000 in arr)
18+
2819

2920
# 4. June month just finished and your expense is 1980 dollar. Add this item to our monthly expense list
30-
exp.append(1980)
31-
print("Expenses at the end of June:",exp) # [2200, 2350, 2600, 2130, 2190, 1980]
21+
22+
arr.append(1980)
23+
print(arr)
3224

3325
# 5. You returned an item that you bought in a month of April and
3426
# got a refund of 200$. Make a correction to your monthly expense list
3527
# based on this
36-
exp[3] = exp[3] - 200
37-
print("Expenses after 200$ return in April:",exp) # [2200, 2350, 2600, 1930, 2190, 1980]
28+
29+
arr[3] = arr[3] - 200
30+
print(arr)

0 commit comments

Comments
 (0)