A Python list (array) with any value/number of elements I wanted to learn about initialization using initialization , but I'm suddenly discussing initialization in the topic "Initialization with arbitrary values and number of elements".
l =  * 10 print (l) # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Just increasing the number of elements of 0 does not tell where this is initialization.
What is the notion of python list initialization or python comprehension initialization?
I'd be happy if you could tell me if you know.
Answer # 1
Also on that site
As mentioned above, Python lists can dynamically add and delete elements, so there are few situations where initialization is necessary, but all elements are filled with arbitrary values. If you want to create a list, use the * operator:
Initializing Python list (array) with arbitrary value and number of elements | note.nkmk.me
. To be clear, it's not much more than that.
It doesn't mean that there is a clear concept of initialization in the first place, it creates a variable or container that has an appropriate value before processing, or fills it with an appropriate initial value after writing (writing and language However, there is no need to "study about initialization" in the first place (or it is impossible). .
Answer # 2
What do you write when the title "Create a 10-element array and initialize all elements to 0" is given?
Comprehensions can be used to write a list or dictionary data concisely.
If you don't use comprehensions, you must create an empty list or dictionary and then add it by looping one element at a time.
L = 
for i in range (10): L.append (0)
Answer # 3
How Python works | Python Tutorial for beginners |
- i have a question about basic python problems
- about processing to exclude the character string group specified from list in python
- python - about hamiltonian neural networks
- python - about write loop to csv
- about python argument and data definition
- python 3x - about downloading anaconda
- python - about the optimum angle of rotation matrix
- python - about downloading youtube videos by youtube-dl
- python - what i don't understand about yolo9000 (v2)
- python - about "" "of" "" select === = "" "
- about batch change of file name using python
- about the python speedtest code
- about the implementation of combinations in python
- please tell me about the role of python tag = "mychr"
- about python def issues
- about the operation of python's speedtest module (library)
- python, about the fire spread step of forest fire simulation
- python - about x-axis adjustment in matplotlib
- about data plotting in python
- python 3x - about return code of python3 subprocess