Create a new program in Repl.it called "Lists." Your goal for this program is to create
sections of code that will perform different outputs with the list called, names which
contains the following values - Peter, Bruce, Steve, Tony, Natasha, Clint, Wanda, Hope,
Danny, Carol and the list called numbers which contains the following values - 100, 50, 10,
1, 2, 7, 11, 17,53,-8, -4,-9,-72,-64, -80. At the beginning of your program, add in any
comments and create the two lists. Then create the following:
1. A loop that will output every other name in the names list.
2. A loop that will output only the positive numbers in the numbers list.
3. A loop that will output the sum of all the values in the numbers list.
4. A loop that will output only the numbers that are odd.
5. A loop that will output only the names that come before "Thor" in the alphabet from
the names list.
6. A loop that will find the maximum or minimum value in the numbers list. This algorithm
requires an additional variable that is assigned to the first element in the list. Then, in a
loop compare each element to the variable. If the element is > (for max) or < (for min),
assign the variable to the element. After the loop, print the variable.
HINT: len() is a helpful method that can be used on strings or lists to determine how
For lists that would mean how many elements are inside and for strings,

Respuesta :

Answer:

Everything but Thor should be right

Explanation:

numberrs = 0

names = ["Peter","Bruce","Steve","Tony","Natasha","Clint","Wanda","Hope","Danny","Carol"]

numbers = [100,50,10,1,2,7,11,17,53,-8,-4,-9,-72,-64,-80]

for index, element in enumerate(names):

 if index %2 == 0:

  print(element)

for numberrs in numbers:

 if numberrs >= 0:

   print (numberrs, end = ' ')

average = sum(numbers) / len(numbers)

print(average)

for numberrs in list(numbers):

 if numberrs % 2 != 0:

   print (numberrs, end = ' ')

for TN in names:

 if TN == "Thor":

   break

else:

 print({TN})

maxmin = numbers[0]

for numberrs in numbers:

 if numberrs < maxmin:

   maxmin = numberrs

print (maxmin)

maxmin=numbers[0]

for numberrs in numbers:

 if numberrs > maxmin:

   maxmin = numberrs

print(maxmin)

The program is an illustration of loops and conditional statements.

Loops are used to perform iterations, while the execution of a conditional statement is dependent on its truth value

The program in Repl.it where comments are used to explain each line is as follows:

#This initializes numberrs to 0

numberrs = 0

#This initializes the name lists

names = ["Peter","Bruce","Steve","Tony","Natasha","Clint","Wanda","Hope","Danny","Carol"]

#This initializes the number lists

numbers = [100,50,10,1,2,7,11,17,53,-8,-4,-9,-72,-64,-80]

#This iterates through the names

for index, element in enumerate(names):

   #This prints every other names

   if index %2 == 0:

       print(element)

#This iterates through the numbers

for numberrs in numbers:

   #This prints all positive numbers

   if numberrs >= 0:

       print (numberrs, end = ' ')

#This calculates the average

average = sum(numbers) / len(numbers)

#This prints the average

print(average)

#This iterates through the numbers

for numberrs in list(numbers):

   #This prints odd numbers

   if numberrs % 2 != 0:

       print (numberrs, end = ' ')

#This iterates through the names

for TN in names:

   #This prints names that come before "Thor"

   if TN == "Thor":

       break

   else:

       print({TN})

#This initializes the minimum to 0

maxmin = numbers[0]

#This iterates through the numbers

for numberrs in numbers:

   #This determines the minimum of the list

   if numberrs < maxmin:

       maxmin = numberrs

#This prints the minimum of the list        

print(maxmin)

#This initializes the maximum to 0

maxmin=numbers[0]

#This iterates through the numbers

for numberrs in numbers:

   #This determines the maximum of the list

   if numberrs > maxmin:

       maxmin = numberrs

#This prints the minimum of the list

print(maxmin)

Read more about similar programs at:

https://brainly.com/question/17140981

ACCESS MORE
EDU ACCESS