Variables are used to store data, they can be assigned values using the assignment operator =
!=
not equal to
append()
adds an item to the end of a list using value
insert()
adds item to a specific position in a list
pop()
removes and stores an item from a specific index in a list. if there is nothing in the brackets, the last item in the list is removed.
len()
gives the length of a list
in
tells you whether an item is in a list
remove()
removes an item from a list using value
del myList []
removes an item from a list using index
sort()
sorts a list in ascending order
for loops
for i in range (0,5,2)
print(i)
will print all even numbers from 0 to 4
0 - the starting index
5 - the ending index
2 - increasing in steps of 2
foriinrange (11)
print(i)
the program automaticallyassumes that you are going up in steps of 1 and starting from the number 0, so it is not necessary to type this.
this will print all the numbers from 0 to 10.
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print (numbers[0: :5])
this prints the numbers 1 and 6, as the program automaticallyassumes that the range is to the end of the list.
while loops
when the condition is True, the indented code will run. When the code is False, the indented code does not run and the program goes on to the next bit of code which is not indented.