-
Notifications
You must be signed in to change notification settings - Fork 8
/
basics.py
101 lines (74 loc) · 2.17 KB
/
basics.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
"""This method should print 'hello world' to the screen. There is no return value for this method."""
def hello_world():
pass
"""
Given a list of integers, find the maximum element.
Input: A list of integers
Output: The maximum value in the list
"""
def find_max(my_list):
return 0
'''
Given a list of integers, determine the maximum number less n.
Input: [1,4,2,14, 11], n = 6
Output: 4
Hint: You may wish to use your find_max function in this function
'''
def find_max_less_than(my_list, n):
return 0
"""
Determine if all characters in the string are unique. Meaning no character occurs more than once.
Input: A string
Output:
True if it is unique
False if the string is not unique
"""
def is_unique(str_in):
pass
"""
Determine the character that occurs most frequently in the input string
Input: A string
Output:
The character that occurs most frequently
"""
def most_common_char(str_in):
pass
"""
Determine if n is prime.
Input: An integer n
Output:
True: if n is prime
False: if n is not prime
"""
def is_prime(n):
pass
'''
Given a string, print out the letters that are capitalized.
Input: 'HellO World'
We should print out the letters 'H', 'O', and 'W'
Hint: the lower() and upper() functions may be userful
'''
def find_capitals(str_in):
pass
"""
Given a series of words separated by spaces, split the statement up into a list where each element is a word.
Input:
'hello World how is it going'
Output:
['hello', 'World', 'how', 'is', 'it', 'going']
Hint: Look up the split() function
"""
def make_list(str_in):
pass
if __name__ == '__main__':
print("Welcome to the Basics Lecture")
hello_world()
list_a = [1,5,43,5,12,155,123]
if find_max(list_a) == 155:
print("You found the correct max value for the first list")
list_b = [i % 123 for i in range(100000)]
if find_max(list_b) == max(list_b):
print("You found the correct max value for the second list")
if(find_max_less_than(list_b, 125) == 122):
print("your find_max_less_than function found the correct value than less n")
#Try writing your own tests for the rest of the problem!