- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaseStudyModule.py
More file actions
Latest commit
84 lines (74 loc) · 2.53 KB
/
Copy pathCaseStudyModule.py
File metadata and controls
84 lines (74 loc) · 2.53 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
importcsv
fromdatetimeimportdatetime, timedelta, date
#tuple
TeamPositionList= ("C", "1B", "2B", "3B", "SS", "LF", "CF", "RF", "P")
#intro
defmenu():
print("="*64)
print(" Baseball Team Manager ")
print()
print("CURRENT DATE (YYYY-MM-DD): ", date.today())
GameDate=str(input("GAME DATE (YYYY-MM-DD): "))
ifGameDate=="":
menuoptions()
else:
GameDate=datetime.strptime(GameDate, "%Y-%m-%d")
DifferenceOfDays=GameDate-datetime.now()
ifDifferenceOfDays<=timedelta(days=0):
menuoptions()
else:
print("DAYS UNTIL GAME:", DifferenceOfDays.days)
menuoptions()
#menu function
defmenuoptions():
print()
print("MENU OPTIONS")
print("1 - Display lineup")
print("2 - Add player")
print("3 - Remove player")
print("4 - Move player")
print("5 - Edit player position")
print("6 - Edit player stats")
print("7 - Exit program")
print()
print("POSITIONS")
print(TeamPositionList[0] +" , "+TeamPositionList[1]+" , "+TeamPositionList[2]+" , "+TeamPositionList[3]+" , "+TeamPositionList[4]+" , "+TeamPositionList[5]+" , "+TeamPositionList[6]+" , "+TeamPositionList[7]+" , "+TeamPositionList[8])
print()
try:
withopen("player_list.csv") asfile:
print("File found")
exceptFileNotFoundError:
print("Team data file could not be found")
print("You can create a new one if you want")
print("="*64)
#batting average function
defbattingaverage(x,y):
ify>0:
BattingAverage=x/y
BattingAverage=round(BattingAverage, 2)
BattingAverage=str(BattingAverage)
returnBattingAverage
else:
BattingAverage=0
returnBattingAverage
defErrorCheckerAtBats(x):
whileTrue:
ifx<0:
print("Error, official times at bat can't be less than 0, please try again.")
print()
x=int(input("Official number of at bats: "))
else:
break
defErrorCheckerHits(x,y):
whileTrue:
ify>x:
print("Error, official at bats can't be greater than number of hits please try again.")
print()
y=int(input("Number of hits: "))
x=int(input("Official number of at bats: "))
elify<0:
print("Error, Can't have negative number of hits, please try again.")
print()
y=int(input("Number of hits: "))
else:
break