-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmyDailySpending
More file actions
90 lines (77 loc) · 2.23 KB
/
myDailySpending
File metadata and controls
90 lines (77 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'''
It calculates the daily cost that you spent, the average, and total amount.
'''
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 7.77, 8.77, 8.66, 9.99]
def average():
t = []
total = 0.0
count = 0
for i in range(len(x)):
total += x[i]
count += 1
print("Total outgoing during", count, "day : %.02f" % total, " €")
print("The average in a day : %.02f" % (total / count), " €")
def muck():
a = []
for i in x:
a += x[i]
return a
def main():
'''
t = []
total = 0.0
count = 0
for i in range(len(x)):
total += x[i]
count += 1
print("Total outgoing during", count, "day : %.02f" % total, " €")
print("The average in a day : %.02f" % (total / count), " €")
'''
t = []
global theYear
theYear = input("Enter the first date : e.g., 31:03:2017 ")
t += theYear.split(":")
firstDay = (int)(t[0])
global theMonth
theMonth = (int)(t[1])
theYear = (int)(t[2])
# print(t)
# print("firstDay", firstDay)
# print("theMonth", theMonth)
# print("theYear", theYear)
for i, j in zip(lala(firstDay, theMonth, theYear), x):
print("{} -> {} €".format(i, j))
def lala(day, month, year):
lastDay = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
theList = []
_month = month
_day = day
if _month == 2:
print("_month", _month)
if isLeapYear(theYear):
lastDay[1] = 29
print("if teki _day", lastDay[1])
else:
print("else teki lastDay[1]", lastDay[1])
for i in range(len(x)):
if ((lastDay[month - 1] == _day) and (months[_month - 1]) == _month):
print("önemliii _day", day)
theList += [("{}:{}:{}".format(_day, month, year))]
_day = 1
if month == 12:
month = 1
year += 1
else:
month += 1
else:
theList += [("{}:{}:{}".format(_day, month, year))]
_day = _day + 1
return theList
def isLeapYear(year):
if ((year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0))):
return True
else:
return False
main()
average()