-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL4 Problems.py
More file actions
51 lines (41 loc) · 1.11 KB
/
L4 Problems.py
File metadata and controls
51 lines (41 loc) · 1.11 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
47
48
49
50
51
def clip(lo, x, hi):
'''
Takes in three numbers and returns a value based on the value of x.
Returns:
- lo, when x < lo
- hi, when x > hi
- x, otherwise
'''
# Your code here
bitLo = min(lo, x, hi) == x
bitX = min(lo, x, hi) == lo and max(lo, x, hi) == hi
bitHi = max(lo, x, hi) == x
result = lo * int(bitLo) + x * int(bitX) + hi * int(bitHi)
return result
print(clip(10, 15, 20))
print(clip(10, 25, 20))
print(clip(10, 5, 20))
def isVowel(char):
'''
char: a single letter of any case
returns: True if char is a vowel and False otherwise.
'''
# Your code here
test_str = char.lower()
if (test_str == 'a' or test_str == 'e' or test_str == 'i' or
test_str == 'o' or test_str == 'u'):
return True
else:
return False
def isVowel2(char):
'''
char: a single letter of any case
returns: True if char is a vowel and False otherwise.
'''
# Your code here
test_str = char.lower()
if test_str in ['a', 'e', 'i', 'o', 'u']:
return True
else:
return False
print(isVowel2('A'))