Problem 6 Create an empty list numbers. Populate the list with the sequence of n
ID: 3726610 • Letter: P
Question
Problem 6
Create an empty list numbers. Populate the list with the sequence of numbers 5, 7, 9, …, 111, 113 using the range function. Problem is similar to problem 1.2 and therefore I reused the code with different initial values
Initial Value 2: 5
Initial Value 3: 115
Initial Value 4: 2
Result: [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113]
write in python
Explanation / Answer
# Adds List Element as value of List.
ini=5
last=115
diff=2
List = []
index=5;
while index < last:
List.append(index)
index=index+2;
print(List)