Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
8
Task/Arrays/Python/arrays-1.py
Normal file
8
Task/Arrays/Python/arrays-1.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
array = []
|
||||
|
||||
array.append(1)
|
||||
array.append(3)
|
||||
|
||||
array[0] = 2
|
||||
|
||||
print(array[0])
|
||||
1
Task/Arrays/Python/arrays-2.py
Normal file
1
Task/Arrays/Python/arrays-2.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
my_array = [0] * size
|
||||
1
Task/Arrays/Python/arrays-3.py
Normal file
1
Task/Arrays/Python/arrays-3.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
my_array = [[0] * width] * height # DOES NOT WORK AS INTENDED!!!
|
||||
1
Task/Arrays/Python/arrays-4.py
Normal file
1
Task/Arrays/Python/arrays-4.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
my_array = [[0 for x in range(width)] for y in range(height)]
|
||||
3
Task/Arrays/Python/arrays-5.py
Normal file
3
Task/Arrays/Python/arrays-5.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
my_array = list()
|
||||
for x in range(height):
|
||||
my_array.append([0] * width)
|
||||
9
Task/Arrays/Python/arrays-6.py
Normal file
9
Task/Arrays/Python/arrays-6.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Retrieve an element directly from the array.
|
||||
item = array[index]
|
||||
|
||||
# Use the array like a stack. Note that using the pop() method removes the element.
|
||||
array.pop() # Pop last item in a list
|
||||
array.pop(0) # Pop first item in a list
|
||||
|
||||
# Using a negative element counts from the end of the list.
|
||||
item = array[-1] # Retrieve last element in a list.
|
||||
6
Task/Arrays/Python/arrays-7.py
Normal file
6
Task/Arrays/Python/arrays-7.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
try:
|
||||
# This will cause an exception, which will then be caught.
|
||||
print(array[len(array)])
|
||||
except IndexError as e:
|
||||
# Print the exception.
|
||||
print(e)
|
||||
1
Task/Arrays/Python/arrays-8.py
Normal file
1
Task/Arrays/Python/arrays-8.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
another_array = my_array[1:3]
|
||||
Loading…
Add table
Add a link
Reference in a new issue