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
What are the first and the last physical memory addressesaccessible using
Misha Larkins [42]

Answer

For First physical memory address,we add 00000 in segment values.

For Last physical memory address,we add 0FFFF in segment values.

<u>NOTE</u>-For addition of hexadecimal numbers ,you first have to convert it into binary then add them,after this convert back it in hexadecimal.

a)1000

For First physical memory address, we add 00000 in segment value

We add 0 at the least significant bit while calculating.

          1000<u>0</u> +00000 = 1000<u>0</u> (from note)

For Last physical memory address,We add 0 at the least significant bit while calculating.

   we add 0FFFF in segment value

           1000<u>0</u> +0FFFF =1FFFF    (from note)

b)0FFF

For First physical memory address,we add 00000 in segment value

We add 0 at the least significant bit while calculating.

     0FFF<u>0</u> +00000=0FFF0 (from note)

For Last physical memory address,We add 0 at the least significant bit while calculating.

   we add 0FFFF in segment value

           0FFF<u>0</u> +0FFFF =1FFEF (from note)

c)0001

For First physical memory address,we add 00000 in segment value

We add 0 at the least significant bit while calculating.

     0001<u>0</u> +00000=00010 (from note)

For Last physical memory address,We add 0 at the least significant bit while calculating.

   we add 0FFFF in segment value

           0001<u>0</u> +0FFFF =1000F (from note)

d) E000

For First physical memory address,we add 00000 in segment value

 We add 0 at the least significant bit while calculating.

    E000<u>0</u> +00000=E0000 (from note)

For Last physical memory address,We add 0 at the least significant bit while calculating.

   we add 0FFFF in segment value

           E000<u>0</u> +0FFFF =EFFFF (from note)

e) 1002

For First physical memory address,we add 00000 in segment value

 We add 0 at the least significant bit while calculating.

    1002<u>0</u> +00000=10020  (from note)

For Last physical memory address,We add 0 at the least significant bit while calculating.

   we add 0FFFF in segment value

           1002<u>0</u> +0FFFF =2001F (from note)

6 0
3 years ago
6.Decreasing a telescope's eyepiece focal length will:
Ghella [55]
B is the correct answer to ur questions
8 0
3 years ago
What is the final gear reduction of a compound gear reduction of 36 to 12 for the first stage and 60 to 12 for the second stage?
OverLord2011 [107]

Answer:

8

Explanation:

Gear reduction = driven gear teeth / driving gear teeth

First stage reduction :

Driven gear teeth = 36

Driving gear teeth = 12

36 /12 = 3

Second stage reduction :

Driven gear teeth = 60

Driving gear teeth = 12

60 /12 = 5

First stage + second stage

3 + 5 = 8

5 0
3 years ago
What is the best description of a programming language?
sergejj [24]

Answer: A: A language that directs a computer to perform tasks and carry out

functions

Explanation: I'm a programmer, and coder, this is the best answer from the given choices

4 0
2 years ago
Which of the following is the correct order for arranging these titles in a subject filing system? A. Applications, Banking Serv
Ket [755]

Answer:

The correct answer is option (A) Applications, Banking Services, Customer Service

Explanation:

Solution

Methods of filing

There are 5 methods of filing:

• Filing by Subject/Category

• Filing in Alphabetical order

• Filing by Numbers/Numerical order

• Filing by Places/Geographical order

• Filing by Dates/Chronological order

In this case, we can fill by Alphabetical order which is given below

Applications, Banking Services, Customer Service

7 0
3 years ago
Other questions:
  • * Declare a variablecalled "car" of type "Car", and initialise its value to a new instance of the "Car"class.
    9·1 answer
  • Options to rotate cells in excel are available using the _____ button in the alignment group on the home tab.
    10·1 answer
  • What are some effective methods for scrolling? Check all that apply.
    6·1 answer
  • Universal Containers has two customer service contact centres and each focuses on a specific product line. Each contact centre h
    7·1 answer
  • How did you generate a random number for the user to guess?
    9·1 answer
  • 30 POINTS PLS HELP AND DONT PUT ANYTHING IF U DK PLS
    5·1 answer
  • Supplies/material used in iron​
    11·1 answer
  • Help brainleist giving exam
    15·1 answer
  • A gui allows you to interact with objects on the screen such as icons and buttons true or false
    15·1 answer
  • Insertion point shows where the typed text will appear.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!