-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject1-507.py
More file actions
46 lines (37 loc) · 1.06 KB
/
project1-507.py
File metadata and controls
46 lines (37 loc) · 1.06 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
import math
# Problem 2. Palindromes
#
# Given a string, determine if the string is a palindrome.
#
# Examples:
# palidrome('anna') returns 'True'
# palidrome('abcdef') returns 'False'
# palidrome('') returns 'True'
def palindrome(word):
### Your code goes here
print('Fill in code for palindrome')
# return '' ### Replace with your code
def test(got, expected):
score = 0;
if got == expected:
score = 3.33;
print(" OK ",end=" ")
else:
print (" XX ", end=" ")
print("Got: ",got, "Expected: ",expected)
return score
def main():
total = 0;
print()
print ('Task C: palindromes' """Each OK is worth five points.""")
# """ If this is what you get, you are good to go. Each OK is worth five points.
# OK Got: True Expected: True
# OK Got: False Expected: False
# OK Got: True Expected: True
# """
total += test(palindrome('anna'), True)
total += test(palindrome('bookkeeper'), False)
total += test(palindrome('a'), True)
print("You final score is: ", math.ceil(total))
if __name__ == '__main__':
main()