Lesson 30 Homework Solutions
unknown
python
2 years ago
1.0 kB
9
Indexable
# Task 1 n = int(input()) numbers = [] for i in range(n): x = int(input()) numbers.append(x) # Task 2 num_list = [1, 2, 3, 4, 5, 10, 2, 3, 1] for i in range(4): num_list.pop() # .pop(-1) also works # Task 3 first_names = ["Grayson", "Sierra", "Curtis", "Victor", "Oscar"] last_names = ["Wang", "Huang", "Zhu"] for firstName in first_names: # looping through first name list for lastName in last_names: # looping through last name list print(firstName, lastName) # Task 4 n = int(input()) m = int(input()) count = 0 for i in range(1, n+1): for j in range(1, m+1): if i + j == 7: count += 1 print(count) # Task 5 n = input() # take input as string group1 = int(n[0]) + int(n[1]) + int(n[2]) # sum of first 3 numbers group2 = int(n[4]) + int(n[5]) + int(n[6]) # sum of next 3 numbers group3 = int(n[8]) + int(n[9]) + int(n[10]) + int(n[11]) # sum of last 4 numbers if group1 == group2 == group3: print("Goony!") else: print("Pick up the phone!")
Editor is loading...