The following program segment should iterate through the list terms and then add each item to the list vocab if it is not already in vocab. If the word is already in vocab, then the program should add 1 to the variable duplicates.
terms = ["accent", "vertigo",
"libra", "illusion"]
vocab = ["hereditary", "illusion",
"vertigo", "velocity", "fallacy"]
duplicates = 0
---
for word in terms:
---
if word not in vocab:
---
if word not in terms: #distractor
---
vocab.append(word)
---
word.append(vocab) #distractor
---
else:
---
duplicates = duplicates + 1
---
duplicates + 1 #distractor
Write code for the function getRange. It should take a list of numbers and return the range (the maximum value minus the minimum value). If we have the list [10, 8, 13, 20, 15], the range would be calculated as 20 - 8 and would be 12.
Write code for the function freezeDays. It should take a list of temperatures temps (in degrees F) and return the number of days that were below 32 degrees.
Hint: You may want to start by printing out each temperature and a “freeze” or “no” message to make sure you can identify the right temperatures. Then worry about counting how many there were.
To calculate the GPA, you need to add up the point value of all the grades. An A is 4, a B is 3, a C is 2, a D is 1, and an F is 0. Then divide by the number of grades in the list.
Hint: First write some if logic that just prints the correct value for each grade (4, 4, 2 for [“A”, “A”, “C”]). Then worry about getting the total of them.