Python please answer P6.3 & P6.4 Write a program that adds all numbers from 2 to
ID: 3685840 • Letter: P
Question
Python please answer P6.3 & P6.4 Write a program that adds all numbers from 2 to 10,000 to a list. Then remove the multiples of 2 (but not 2), multiples of 3 (but not 3), and so on, up to the multiples of 100. Print the remaining values.. Write list functions that carry out the following tasks for a list of integers. For each function, provide a test program. Swap the first and last elements in the list. Shift all elements by one to the right and move the last element into the first position. For example, 1 4 9 16 25 would be transformed into 25 1 4 9 16. Replace all even elements with 0. Replace each element except the first and last by the larger of its two neighbors. Remove the middle element if the list length is odd, or the middle two elements if the length is even. Move all even elements to the front, otherwise preserving the order of the elements. Return the second-largest element in the list. Return true if the list is currently sorted in increasing order. Return true if the list contains two adjacent duplicate elements. Return true if the list contains duplicate elements (which need not be adjacent). Modify the largest. py program in Section 6.3 to mark both the smallest and the largest elements. Write a function sumWithoutSmallest that computes the sum of a list of values, except for the smallest one, in a single loop. In the loop, update the sum and the smallest value. After the loop, return the difference. Write a function removeMin that removes the minimum value from a list without using the min function or remove method. Compute the alternating sum of all elements in a list. For example, if your program reads the input. Write a function that reverses the sequence of elements in a list. For example, if you call the function with the listExplanation / Answer
Hi below i have given the method for P6.3 for your reference,
# Program that adds all numbers from 2 to 10,000 to a list.
# Then remove the multiples of 2 (but not 2), multiples of 3 (but not 3),
# and so on, up to the multiples of 100. Print the remaining values.
# PROGRAM RUN
# add all numbers from 2 to 10,000
list = []
for i in range(2, 101):
list.append(int(i))
lenList = len(list)
print(lenList)
for i in range(lenList):
for j in range(2, 101):
if lenList[i] != j and lenList[i] % j == 0:
sum =0
# print the remaining numbers
for element in list:
print(element)
P6.4
Return the second largest element in the list in
Swap the first and last element in the list
Return true if the list is currently sorted in the increasing order
Return true if the list contains two adjacent duplicate elements
Return true if the list contains duplicate elements
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.