#Defining the List
aList= [1,4,2,6,7,3,]
# Accessing Elements in a list
print(aList[1])
#Storing Element at an Index to a variable
Element = aList[3]
print(Element)
#Setting an Element at an Index to a variable
element = 4
aList[5]= element
print(aList[5])
#Insert a value at a certain index
aList.insert(3, 10)
print(aList[3])
#Adding another value to the list (append)
aList.append(5)
print(aList)
#Removing a value from the List at a specific Index
aList.remove(2)
print(aList)
#Accessing the Length of a list
print(len(aList))
4
6
4
10
[1, 4, 2, 10, 6, 7, 4, 5]
[1, 4, 10, 6, 7, 4, 5]
7
#Enter code here
numList = [1, 4, 6, 9, 10, 12, 14, 16]
numList.insert(1, 2)
print(numList[1])
nums = [30, 45, 95, 56, 73, 98, 25]
min_value = nums[4] # Start with the first element as the minimum
for score in nums:
if score < min_value:
min_value = score
print(min_value) # Display the minimum value
#Enter Code here
nums = [30, 45, 95, 56, 73, 98, 25]
max_value = nums[4] # Start with the first element as the minimum
for score in nums:
if score > max_value:
max_value = score
print(max_value) # Display the minimum value
#Defining numbers in list
nums = [7, 5, 10, 6, 9, 4, 3, 12]
sum_even = sum([score for score in nums if score % 2 == 0]) #Using for loop to work through each number in the list and using mod to interpret if any numbers have a remainder of 0
print(sum_even)
['computer', 'science', 'potato']
fruits= ['Apple', 'Carrot', 'Mango', 'Peach']
A= [1, 3, 5, 8, 9, ]
B= [6, -1, 5, 12, 8]
#Type your choices below
# 1) The middle index number will be 3 (the array value associated with this index would be 12)
# 2) Lists 'fruits' and 'A' can use a binary search to find the desired target.
numsList = [8,10,35,39,49,52]
numsList.insert(0, 2) # operation 1
print(numsList[0])
numsList.append(68) # operation 2
print(numsList)
numsList.remove(39) # operation 3
print(numsList)
sum_odd = sum([score for score in numsList if score % 2 == 1]) # operation 4
print(sum_odd)
#type out your answers below and run the code and include output in screenshot
2
[2, 8, 10, 35, 39, 49, 52, 68]
[2, 8, 10, 35, 49, 52, 68]
84