# Quiz 2 Review
Notes
# Quiz 2 Review #definite (FOR), indefinite (WHILE) # range(start, end, step) range(0,10,3) -> 4 iterations #append(data) add to back of list, insert(index, data) add to somewhere specific lst = [1,2,3] for num in lst: num = num * 2 print(lst) # lst does not change # it should be print(num) not lst, because we are doubling num, not lst #[0, 1, 2, 3, 4] # pop(2) -> index[2] -> 3 is removed -> [1, 2, 4] -> index [2] = 4 # [2, 4, 6, 8] -> pop() = pop(-1) = index (-1) = 8 # range(10, 30, 10) -> start = 10, end = 99, step = 10 -> (10, 29) -> [10,20] # [4, 5, 7] -> print([4, 5, 7]).remove(7)) lst = [4, 5, 7] print(lst.remove(4)) #remoe function returns none print(lst) # good = 'yes' # while good != 'yes': # print('Very Good') # this never runs as long as good == "yes" # Programming 1 campus = [] name = input("Please enter name of a UC Campus: ") while name != '': campus.append(name) name = input("Please enter name of a UC Campus: ") for idx in range(len(campus)): if 'SD' in campus[idx]: campus[idx] = '' print(campus) # Programming 2 for num in range(0,10): if num % 2 == 1: #odd number print(num)
Study with interactive games
Upload your notes and generate flashcards, exams and more with AI
Start for free