answer.
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]
2 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]2 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
Choose the reasons why Windows Server operating systems are a popular choice for a network because they _____. Select all that a
____ [38]

Answer:

The answers are -

work on networks that include using Windows operating systems as well as Mac OS, NetWare, or UNIX

provide a graphical user interface that makes it easier for network administrators to learn the system

use wizards and setup devices as the user operating system, making it easier to set up network features

Explanation:

5 0
2 years ago
In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2)
kodGreya [7K]

Answer:

SyntaxError.

Explanation:

https://www.quora.com/In-Python-what-kind-of-error-is-returned-by-the-following-code-e-g-NameError-ValueError-IOError-etc-def-my_func-n1-n2-return-n1-n2-my_func-1-2-3          sorce site

<h2></h2><h2></h2><h2></h2><h2>brainlest plz</h2>
6 0
2 years ago
Carefully choosing from a set of alternatives to accomplish an objective is known as? A. Independence B. Decision making C. Netw
Contact [7]
<span>I think it would beB. Decision making</span>
8 0
2 years ago
Read 2 more answers
. When you have multiple graphics positioned on a page, you can _______________ them so that they are a single graphic instead o
alisha [4.7K]
The best answer is B
i hope its help
8 0
2 years ago
Which set of variables will make code easier to understand?
Alecsey [184]

Answer:

sum, price, count

Explanation:

Programmers should use significant names for the variables.

Not only it makes it easier for them to remember what kind of information is stored in each variable, but it also makes life simpler for anyone who would read the code later.

Names like sum, price and count are significant names ( assuming they actually hold this kind of data), and will make the re-reading of the program code much easier.

8 0
2 years ago
Other questions:
  • In three to five sentences, describe whether or not files should be deleted from your computer.
    13·2 answers
  • Suppose a digital camera has a storage capacity of 256mb. how many photographs could be stored in the camera if each consisted o
    8·1 answer
  • Static packet filtering firewalls are limited to ________. inspecting packets for which there are good application proxy filteri
    8·1 answer
  • Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off. The follow
    7·1 answer
  • Your network administrator finds a virus has been successfully inserted into the network software. The virus itself is now consi
    10·2 answers
  • The function below takes two integer parameters: low and high. Complete the function so that it prints the numbers from low to h
    14·1 answer
  • (a) Show how to use (the Boolean formula satisfiability program) satisfiable num (and substitute) to find a satisfying assignmen
    9·1 answer
  • Write code that determines the number of full days represented by the number of hours stored in the variable hours and stores th
    15·1 answer
  • To create a public key signature, you would use the ______ key.
    5·1 answer
  • Docker is focused on ______ containerization.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!