File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ def main ():
2
+ greeting = input ("Greeting: " )
3
+ print (value (greeting ))
4
+
5
+ def value (greeting ):
6
+ if "hello" in greeting .lower ().strip () :
7
+ return "$0"
8
+ elif greeting .lower ().strip ().startswith ('h' ):
9
+ return "$20"
10
+ else :
11
+ return "$100"
12
+
13
+
14
+ if __name__ == "__main__" :
15
+ main ()
16
+
Original file line number Diff line number Diff line change
1
+ from bank import value
2
+
3
+ def main ():
4
+ test_hello ()
5
+ test_greeting_starts_with_h ()
6
+ test_other_greeting ()
7
+
8
+
9
+ def test_hello ():
10
+ assert value ("hello" ) == "$0"
11
+ assert value (" hello " ) == "$0"
12
+
13
+ def test_greeting_starts_with_h ():
14
+ assert value (" hi" ) == "$20"
15
+ assert value ("How you doing?" ) == "$20"
16
+
17
+ def test_other_greeting ():
18
+ assert value ("What's happening?" ) == "$100"
19
+
20
+ if __name__ == "__main__" :
21
+ main ()
You can’t perform that action at this time.
0 commit comments