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
Anna11 [10]
3 years ago
14

Create an array w with values 0, 0.1, 0.2, . . . , 3. Write out w[:], w[:-2], w[::5], w[2:-2:6]. Convince yourself in each case

that you understand which elements of the array that are printed.
Computers and Technology
1 answer:
larisa86 [58]3 years ago
6 0

Answer:

w = [i/10.0 for i in range(0,31,1)]

w[:]  = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0]

w[:-2] = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8]

w[::5]= [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]

w[2:-2:6] = [0.2, 0.8, 1.4, 2.0, 2.6]

Explanation:

List slicing (as it is called in python programming language ) is the creation of list by defining  start, stop, and step parameters.

w = [i/10.0 for i in range(0,31,1)]

The line of code above create the list w with values 0, 0.1, 0.2, . . . , 3.

w[:]  = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0]

since start, stop, and step parameters are not defined, the output returns all the list elements.

w[:-2] = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8]

w[:-2] since  stop is -2, the output returns all the list elements from the beginning to just before the second to the last element.

w[::5]= [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]

w[::5] since  step is -2, the output returns  the list elements at index 0, 5, 10, 15, 20, 25,30

w[2:-2:6] = [0.2, 0.8, 1.4, 2.0, 2.6]

the output returns the list elements from the element at index 2  to just before the second to the last element, using step size of 6.

You might be interested in
You are assigned by your teacher to perform the assembly of all the parts of the computer in preparation for the hands on activi
Alexus [3.1K]

Answer:

answer it yourself or ask your teacker

Explanation:

7 0
2 years ago
Which of the following translates packets so that the node can understand them once they enter through a port?
podryga [215]
Hi
D)A NICHappy to assist you!
8 0
3 years ago
Read 2 more answers
What is the name of the finned metal device that radiates heat away from the processor?
dezoksy [38]
This is called a "heat sink", essentially, a metal plate makes indirect <span>(its separated by thermal paste)</span> contact with the heat spreader of a cpu (central processing unit). The concept is that the heat sink is made of highly conductive materials thus conducting heat away from the CPU, quite often you'll find a fan attached to further disparate heat away from the heat-sink. These days you'll alternative cooling methods, the most common alternative is to use watercooling (another topic). GPU (graphic processing units) also have heatsinks.    
3 0
3 years ago
If several programs or apps are running simultaneously, your computer or device might use up its
kirill [66]

Answer: I am pretty sure it's RAM

Explanation:

I'm not 100% positive bc I haven't gotten my scores back yet but I think that's it.

7 0
3 years ago
For any element in keysList with a value greater than 60, print the corresponding value in itemsList, followed by a semicolon (n
nika2105 [10]

Answer:

Below are the python Program for the above question:

Explanation:

keysList =[1,61,68,64]#key list items.

itemsList =[1,2,3,4]#item list items.

for x in range(len(keysList)):#for loop.

   if(keysList[x]>60):#check the value to be greator.

       print(itemsList[x],end=";")#print the value.

Output:

  • The above code will print as "2;3;4;".

Code Explanation:

  • The above code is in python language, in which the first and second line of the code defines a list. That list can be changed by the user when he wants.
  • Then there is a or loop that scans the keylist items and matches the items that it is greater than 60 or not. If it then takes the location and prints the itemlist by the help of that location.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Shut down and unplug the computer. Remove the CPU case lid. Locate the various fans, and then use
    11·1 answer
  • Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently long such tha
    7·1 answer
  • Given positive integer num_insects, write a while loop that prints that number doubled up to, but without exceeding 100. Follow
    8·1 answer
  • You wish to lift a 12,000 lb stone by a vertical distance of 15 ft. Unfortunately, you can only generate a maximum pushing force
    6·1 answer
  • If you create and invoke a recursive function without accounting for a base case, what can go wrong?
    15·1 answer
  • The ____ command is used to disconnect a datatable object from the database. (
    15·2 answers
  • Which of the following accessories would you use to create a drawing? A. Calculator B. Notepad C. Paint D. WordPad
    14·2 answers
  • When approaching a bicyclist from the rear, you should slow down and
    8·1 answer
  • For this exam review lab exercise, you will develop a program that fixes faulty data in a one-dimensional array of integers. Fau
    8·1 answer
  • What service determines which resources a user can access along with the operations that a user can perform?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!