-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloopchallenges.py
More file actions
75 lines (54 loc) · 1.65 KB
/
Copy pathloopchallenges.py
File metadata and controls
75 lines (54 loc) · 1.65 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#Write your function here
def divisible_by_ten(nums):
count = 0
for x in nums:
if x % 10 == 0:
count += 1
return count
#Uncomment the line below when your function is done
print(divisible_by_ten([20, 25, 30, 35, 40]))
#Write your function here
def add_greetings(names):
name_greet = []
for name in names:
name_greet.append("Hello, " + name)
return name_greet
#Uncomment the line below when your function is done
print(add_greetings(["Owen", "Max", "Sophie"]))
#Write your function here
def delete_starting_evens(my_list):
print(my_list)
for number in my_list:
if my_list[0] % 2 == 0:
my_list.remove(number)
print(my_list)
return my_list
#Uncomment the lines below when your function is done
print(delete_starting_evens([4, 8, 10, 11, 12, 15]))
#print(delete_starting_evens([4, 8, 10]))
#Write your function here
def delete_starting_evens(my_list):
while (len(my_list) > 0 and my_list[0] % 2 == 0):
my_list = my_list[1:]
return my_list
#Uncomment the lines below when your function is done
print(delete_starting_evens([4, 8, 10, 11, 12, 15]))
#print(delete_starting_evens([4, 8, 10]))
#Write your function here
def odd_indices(my_list):
new_list = []
for number in my_list[1::2]:
new_list.append(number)
return new_list
#Uncomment the line below when your function is done
print(odd_indices([4, 3, 7, 10, 11, -2]))
#Write your function here
def exponents(bases, powers):
raised_list = []
for number in bases:
for ext in powers:
add = number ** ext
raised_list.append(add)
return raised_list
#Uncomment the line below when your function is done
print(exponents([2, 3, 4], [1, 2, 3]))