forked from inspirezonetech/TeachMePythonLikeIm5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enumerate.py
60 lines (45 loc) · 1.61 KB
/
enumerate.py
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
# ------------------------------------------------------------------------------------
# Tutorial: brief description of tutorial content
# ------------------------------------------------------------------------------------
# Enums are set of symbolic names bound to unique constant values.
# Example, we can have Month enumeration with 12 months
from enum import Enum
class Month(Enum):
JAN = 1
FEB = 2
MAR = 3
APR = 4
MAY = 5
JUN = 6
JUL = 7
AUG = 8
SEP = 9
OCT = 10
NOV = 11
DEC = 12
# Access via Name
feb_elem = Month.FEB
print("Number for Month {name} is {value}".format(name=feb_elem.name,
value=feb_elem.value))
# Access via Value
feb_elem = Month(2)
print("Number for Month {name} is {value}".format(name=feb_elem.name,
value=feb_elem.value))
# ------------------------------------------------------------------------------------
# Challenge: list challenges to be completed here. minimum of one challenge per tutorial
# ------------------------------------------------------------------------------------
# # Challenge 1: Create Enum which store Day of week and Color as value for each day
# # Replace the question(?) with logic
# class ColorWeek(?):
# MONDAY = 'RED'
# TUESDAY = 'GREEN'
# WEDNESDAY = 'BLUE'
# THURSDAY = 'CYAN'
# FRIDAY = 'YELLOW'
# SATURDAY = 'WHITE'
# SUNDAY = 'BLUE'
# if ColorWeek.MONDAY.value == ?:
# print("Color for Monday is RED")
# # Print the day when color is GREEN
# print("Day with color GREEN is: ")
# print(?)