Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Python for the problem below. Please be sure to include documentation/comments accordingly. Create a new program in Python called Lists. Your goal for this

Use Python for the problem below. Please be sure to include documentation/comments accordingly.

Create a new program in Python 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 "long" they are. For lists, that would mean how many elements are inside and for strings, that would mean how many characters long it is.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago