1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OlgaM077 [116]
2 years ago
11

Provide your own examples of the following using Python lists. Create your own examples. Do not copy them from another source. N

ested lists The “*” operator List slices The “+=” operator A list filter A list operation that is legal but does the "wrong" thing, not what the programmer expects Provide the Python code and output for your program and all your examples.
Computers and Technology
1 answer:
leonid [27]2 years ago
6 0

Lists are used in Python to hold multiple values in one variable

<u>(a) Nested list</u>

A nested list is simply a list of list; i.e. a list that contains another list.

It is also called a 2 dimensional list.

An example is:

nested_list = [[ 1, 2, 3, 4]  , [ 5, 6, 7]]

<u>(b) The “*” operator </u>

The "*" operator is used to calculate the product of numerical values.

An example is:

num1 = num2 * num3

<u>List slices </u>

This is used to get some parts of a list; it is done using the ":" sign

Take for instance, you want to get the elements from the 3rd to the 5th index of a list

An example is:

firstList = [1, 2 ,3, 4, 5, 6, 7]

secondList = firstList[2:5]

<u>The “+=” operator </u>

This is used to add and assign values to variables

An example is:

num1 = 5

num2 = 3

num2 += num1

<u>A list filter </u>

This is used to return some elements of a list based on certain condition called filter.

An example that prints the even elements of a list is:

firstList = [1, 2 ,3, 4, 5, 6, 7]

print(list(filter(lambda x: x % 2 == 0, firstList)))

<u>A valid but wrong list operation</u>

The following operation is to return a single list, but instead it returns as many lists as possible

def oneList(x, myList=[]):

   myList.append(x)

   print(myList)

oneList(3)

oneList(4)

Read more about Python lists at:

brainly.com/question/16397886

You might be interested in
Which of the following can a cell contain?
Ksju [112]
The answer is choice D-All of these :)
8 0
3 years ago
Read 2 more answers
What are the three main components of a for loop?
insens350 [35]

Answer:

Similar to a While loop, a For loop consists of three parts: the keyword For that starts the loop, the condition being tested, and the EndFor keyword that terminates the loop.

Explanation:

Loop statements usually have four components: initialization (usually of a loop control variable), continuation test on whether to do another iteration, an update step, and a loop body.

8 0
3 years ago
I can't find my grandson someone help
Artemon [7]

Answer:

i'm right here

Explanation:

grandma

8 0
2 years ago
Read 2 more answers
Pls someone help me with these four questions
ipn [44]

Answer:

16. Grace Hopper. 1959.

8 0
3 years ago
This function whose primary purpose is to display information to the user can only display one value at a time.
Leya [2.2K]

Answer:

False

Explanation:

The functions that was made for display content can get  arguments of different type e.g. (Int, string, Array, Objects) and if you want to display n values you only have to check the syntax of your programming language to separate one of each other

# Python example

a = "Hello-"

b = "World"

c = 10

print(a,b,c)

#Out: Hello-World10

I hope it's help you.

4 0
3 years ago
Other questions:
  • Which of the following would an interactive media proffessional must likely need
    9·1 answer
  • The memory allocated for a float value is ____ bytes.
    9·1 answer
  • Which method allows a computer to react accordingly when it requests data from a server and the server takes too long to respond
    5·1 answer
  • An anagram is a word or a phrase made by transposing the letters of another word or phrase; for example, "parliament" is an anag
    7·1 answer
  • Last week, a disk containing CSM Tech Publishing’s current project manuscripts crashed. Fortunately, there was a backup, but all
    15·1 answer
  • How to write email abut new home your friend ​
    14·1 answer
  • Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(l
    5·1 answer
  • Pls help me<br> first one to answer correctly gets brainly points
    6·2 answers
  • Hi am feeling really happy just passed a test after a lot of tries :-)
    5·1 answer
  • Desktop computers have a(n) ________ unit, located within the system unit, that plugs into a standard wall outlet, converts AC t
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!