Imagine, if the world is full of robot that use Python language and if you don’t know anything about python language, what will you do? What can you help to save the world that full of evil robot?. So from now on, you should learn python to get to know, what it is and how can it work.
This is the following round from the last round. We still continues learning Python from the last round. This round we have learn about Python Dictionary and Python List. Python dictionary is the collections of item that is changeable. You need to write it with curly bracket { }. It doesn’t allow duplicate the items of the code. For Python list, it is the collection of items that is ordered and changeable. It allow duplicate the items of the code. In order to make it work, you need to write it with the square bracket [ ]. Now, let’s me talk about how to access the items. There are many different types of list. There are Assessing Items, change items value, loop through a list, check if items exist, list length, add items – append, add items – insert and remove items. You already see that, there are many types of list, so I will pick Assessing items to explain you. To print it you need to put the words print(the name of your function) and put the number with inside the square bracket and it’s will print out the order of your code. This is so complicated right? It’s okay, I’ll try my best to explain. So in this explain, I’ll use the variable call thislist. In python, they count from zero, so if you write the words like, banana, apple, cherry and grape, and you want to print the number one you need to write the print like this → print(thislist[1]). The outcome will be apple because python count from zero and the value of zero is banana.
You can do a lot thing in Python dictionary. For examples, you can change the values of the item, you can loop through the dictionary, check if item exist or remove some of loop. For me this is a little bit complicated, but I’ll try to explain it as much as I can. Example, when you want to print an information about someone, you want to include her name, her age, her birthday and her favorite band, you can use this code to help you print all the information that you want to get. So first, you need to name your variable. Let say you name your variable as Importantpeople. Then, you need to put an equal sign after your variable and put a curly bracket. After that you enter one to get to the down part and you can write your information. For this, you need to add quotation mark for that words. After that you need to put the colon between the two words. Here, I’ll write down for you.
Importantpeople = {
“name” : “Kakrona Pos”
“age” : “14 years old”
“birthday” : “1st, Sep, 2004”
“Favorite band” : “Seventeen”
}
print(Importantpeople)
Up there is all what I’m trying to explain you. You see? You need to put quotation mark in each word so that it can print out and the result that it will print, it will be
Name Kakrona Pos
Age 14 years old
Birthday 1st, Sep, 2004
Favorite band Seventeen
The summarize of what I’ve learn from Multimedia class is Python Dictionary is use for seeing the keys and values of the code. Python list is use for organize the list of your item and make it to an easy code to look and to read. For this round, I feel like I understand it better than last round :).