The first thing I did in this is made a list called ages, put random values in and then checked them by printing the list and seeing if everything was correct.
The next thing I did was changing an element of the list by referencing the index number. To do this all you have to do is write the name of the list "ages" and then in square brackets [] type the index number you want to change. For example I have done "ages[1]=18" this now means that index 1 in the list has now been changed to 18, even though previously it was 19.
After that I did another basic thing which was adding to a list using append. This is pretty simple as all you have to do is type the name of the list, .append it and then type whatever you want to add to the list in brackets (). For example "ages.append(12)"
Then we move on to inserting a value into the middle of the list. I did this using insert. This is also very simple as all you have to do is type the name of the list, .insert it and then in brackets the index where you want to input the value and then the value. So I did, "ages.insert(6,14)". This means that the value "14" will be inserted into the list called ages at the 6th position.
Moving on, you can also count the number of duplicates you have in your list. This can be done using the count function. For this all you need to do is type the name of the list, .count it and then in brackets type the value you want to check the duplicates for. You also have to print this to actually be able to see how many duplicate values you actually have. For example what I did was "print(ages.count(12))". This will print the amount of times "12" is in the list.
Finally we have come on to Stacks & Queues. A Stack is a list with a first in, last out (FILO) mechanism for managing elements where the last item added is the first item removed.
Basically what the code I have written for stack does a basic thing, firstly it prints the stack which is in range 19, so all values from 0-18 will be printed. Then I append to the stack and add 19 into the stack. After that comes the fun part, we start to pop the stack. Popping in stacks means that you are getting rid of the last value in the stack, so after popping 2 values our stack will only have values from 0-17 as 18 and 19 have been popped off.
A queue is a list with a first in, first out (FIFO) mechanism for managing elements where the first item added is the first item removed. We start of doing exactly what did for stacks and make the range 19 so we will have values from 0-18, after this I decided to append 3 more values into the queue being 20,21 and 22. Then I made a variable "n" and made its value the first value in the queue and then I removed it. So in the queue the first value that has been inputted is the first one out. So after removing "n" we have values from 1-18 + 20,21,22.
Basically what the code I have written for stack does a basic thing, firstly it prints the stack which is in range 19, so all values from 0-18 will be printed. Then I append to the stack and add 19 into the stack. After that comes the fun part, we start to pop the stack. Popping in stacks means that you are getting rid of the last value in the stack, so after popping 2 values our stack will only have values from 0-17 as 18 and 19 have been popped off.
A queue is a list with a first in, first out (FIFO) mechanism for managing elements where the first item added is the first item removed. We start of doing exactly what did for stacks and make the range 19 so we will have values from 0-18, after this I decided to append 3 more values into the queue being 20,21 and 22. Then I made a variable "n" and made its value the first value in the queue and then I removed it. So in the queue the first value that has been inputted is the first one out. So after removing "n" we have values from 1-18 + 20,21,22.




