numbers = [0,1,2,3,4,5,6,7,8,9,10]#sequencing
evens = []#sequencing
for i in numbers:#selection
if (numbers[i] % 2 == 0):#iteration
evens.append(numbers[i])
print(evens)
numbers = [0,1,2,3,4,5,6,7,8,9,10]#sequencing
odd = []#sequencing
for i in numbers:
if (numbers[i] % 1 == 0):#selection
odd.append(numbers[i])#iteration
print(odd)
given the following code segment below: a ⟵ 7
b ⟵ 1
c ⟵ 3
d ⟵ 4
a ⟵ b
b ⟵ c + d
d ⟵ b
find the value for a, b, c, d
Answer = a = 1, b = 7, c = 3, d = 7
A = 1 because even though a =7 at the start, it turns into 1 when b = a b = 7 because b starts off at 1 and then b turns into a which is 7 c = 3 because 3 = c d = c + d =7
consider the following code segment: hot ⟵ true
cold ⟵ false
cold ⟵ hot
hot ⟵ cold
what are the values of hot and cold after executing the code segment?
the value of hot is true, the value of cold is true the value of hot is false, the value of cold is true the value of hot is true, the value of cold is false the value of hot is false, the value of cold is false
Answer = the value of hot is true, the value of cold is true
num1 = 12 num2 = 18 num3 = 2 num1 = num2 + num3 num3 = num1 + num2
What is value of num1 and num3?
Num1 = 20 Num3 = 30
num1 = 4 num2 = 1 num3 = 28 num2 = num1 + num3 num1 = num3 + num2
What is value of num1 and num3?
Num2 = 32 Num1 = 29
Test 1
firstName <- "Bob" lastName <- "Smith" var <- substring(firstName, 1, 1) name <- concat(lastName, var) email <- concat(name, "@gmail.com") DISPLAY(email)
What would the result be?
SmithB@gmail.com
Test 2
word1 <- "computer" word2 <- "textbooks" length1 <- len(word1)/2 length2 <- len(word2)/3 first <- substring(word1, 2, len1) second <- substring(word2, len2+3, len2) newWord <- concat(first, second) DISPLAY(newWord)
ompuook