-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab-11.py
116 lines (72 loc) · 1.67 KB
/
lab-11.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
def min_of_2(x, y):
""" (number, number) -> number
Returns the smaller number
"""
if (x < y):
return x
else:
return y
#stub
#def shortest_name(x):
# """ (list of strings) -> str
#
# Returns the shortest name in a
# list of names
# """
# return ""
#template
#def shortest_name(x):
# """ (list of strings) -> str
#
# Returns the shortest name in a
# list of names
# """
# for i in x:
# ...
# return ...
def shortest_name(x):
""" (list of strings) -> str
Returns the shortest name in a
list of names
"""
for i in x:
min = min_of_2(x[0], len(i))
return min
print(shortest_name("Papa, Ate"))
def num_words_in(word):
""" str -> number
Returns the number of words in a
given string
"""
for i in word:
...
return ...
def LCM(a, b):
""" (int, int) -> number
Determines the least common multiple
a given pair of integers
"""
for i in b:
...
return ...
def is_smallest_to_highest(sth):
""" (list of numbers) -> bool
Determines if a list of numbers
is sorted from smallest to largest
values
"""
for i in sth:
for
return
def list_of_first_cubes(n):
""" (int) -> (list of ints)
Creates a list of the first n cubes,
assuming 1 is the first cube
"""
first_cubes = []
for i in range(1, (n + 1)):
for ch in i:
cube = first_cubes + [ch ** 3]
return cube
list_of_first_cubes(3)
list_of_first_cubes(4)