new tasks

This commit is contained in:
Ingy döt Net 2013-04-09 00:46:50 -07:00
parent 2a4d27cea0
commit 80737d5a6a
1194 changed files with 15353 additions and 1 deletions

View file

@ -0,0 +1 @@
myArray = [0] * size

View file

@ -0,0 +1 @@
myArray = [[0]* width] * height] # DOES NOT WORK AS INTENDED!!!

View file

@ -0,0 +1 @@
myArray = [[0 for x in range(width)] for y in range(height)]

View file

@ -0,0 +1,3 @@
myArray = list()
for x in range(height):
myArray.append([0] * width)

View 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.

View 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

View file

@ -0,0 +1,8 @@
array = []
array.append(1)
array.append(3)
array[0] = 2
print array[0]