-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.py
56 lines (15 loc) · 1.88 KB
/
main.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
# 1. Write a function called shout that takes in a string as an argument and returns it in all caps.
# 2. Write a function called whisper that takes in a string as an argument and returns it in all lowercase.
# 3. Write a function called how_many_letters that takes in a string as an argument and returns the number of letters in that string.
# 4. Write a function called work_it that takes in a string as an argument and returns it backwards and with the first letter capitalized.
# For example, work_it("I put my thing down flip it and reverse it") would return "Ti esrever dna ti pilf nwod gniht ym tup i"
# 5. Write a function called repeat_it that takes in a word and a number, and returns the word that many times.
# For example, repeat_it("Banana", 3) would return "BananaBananaBanana"
# 6. Write a function called will_it_nametag that takes in a name and a number, and tells you whether the name can be printed on a nametag that size.
# For example, will_it_nametag("Peter", 10) will return True, but will_it_nametag("Peter", 4) will return False, because "Peter" is 5 letters long, and needs at least 5 spaces to fit on a nametag.
# 7. Write a function called add_liar that takes in two numbers and prints out a lie like "Sorry, I don't know how to add ___ and ___."
# BUT even though it *prints* that it doesn't know the answer, have the function return the correct answer anyways.
# 8. CHALLENGE: Now that you've written all these functions, try combining them. what would happen if you tried to call repeat_it(work_it("Stressed"), 3) ?
# 9. MEGA CHALLENGE: Write a function called doubler that takes in a string and returns it with every letter doubled.
# For example, doubler("Lost in the Woods") would return "LLoosstt iinn tthhee WWooooddss"
# 10. SUPER MEGA CHALLENGE: Head to https://codingbat.com/python/String-2 and attempt some of the challenges there!