-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment_02.py
executable file
·67 lines (53 loc) · 1.77 KB
/
assignment_02.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
61
62
63
64
65
66
67
__author__ = 'Chaithra'
notes = '''
Fill up each of this methods so that it does what it is intended to do. Use
only the standard data types we have seen so far and builtin functions.
builtin functions: http://docs.python.org/2/library/functions.html
Do not use any control flow statements (if, for...) in this assignment.
Assume that inputs are valid and of expected type, so no checking required.
use constants from string module (string.XXXX) as required.
'''
from placeholders import *
import string
def get_lower_to_upper_dict():
"""
returns a dict which contains a mapping from lower case letters to upper case letters
Hint: see the constants in the string module, and the zip builtin function
"""
str1 = list(string.ascii_lowercase)
str2 = list(string.ascii_uppercase)
res = zip(str1,str2)
result = dict(res)
return result
def get_digit_to_string_dict():
"""
return a dict which maps every digit to its string representation.
Hint: same as above.
"""
list1 = range(0,10)
list2 = list(string.digits)
res = zip(list1,list2)
result = dict(res)
return result
three_things_i_learnt = """
-
-
-
"""
time_taken_minutes = ___
def test_lower_to_upper_dict():
lower_to_upper = get_lower_to_upper_dict()
assert 26 == len(lower_to_upper)
for x in lower_to_upper:
y = lower_to_upper[x]
assert 1 == len(x)
assert x.islower()
assert 1 == len(y)
assert y.isupper()
assert x.upper() == y
def test_digit_to_string_dict():
digit_to_string = get_digit_to_string_dict()
assert 10 == len(digit_to_string)
for x in range(0,10):
assert x in digit_to_string
assert digit_to_string[x] == str(x)