In this round 3 of the year, we learn lots of new things in Multimedia class. We always have assignment after learning something new to practice and know more about it. All of the Multimedia classes uses Codeboard.io to do our assignments. Let me tell you about all of the stuff that we had learned.
- The first thing that we had learned is Boolean and it is a data type that can have value True or False. Example: “cat” is not “dog”. This is True because cats and dogs are different.
- The second thing that we had learned is Comparison. It is the same as math like to compare numbers, but the writing is a bit different and it look like this-
- a == b (Equals)
- a != b (Not Equals)
- a < b (Less than)
- a <= b (Less than or equal to)
- a > b (Greater than)
- a >= b (Greater than or equal to)
- The third thing that we had learned is the If Statement. We use it to make something happen if the code is the True condition. Example:
- a = 100
- b = 200
- if b < a:
- Print “b is greater than a”
- The Fourth things that we had learned is indentation. It is the action of indenting or the state of being indented. It is important because if you put it in the wrong place, the code will be error. One of the right indentation is up there on the last example and this is the wrong indentation:
- a = 100
- b = 200
- if b < a:
- Print “b is greater than a”
- The fifth thing that we had learned is the Elif statement which is a statement with a condition contain value of neither True or False and it follow the If Statement. Example:
- a = 100
- b = 200
- if b < a:
- Print “b is smaller than a”
- Elif b > a:
- Print “b is greater than a”
- The sixth thing that we had learned is the Else statement and it is the similar to the Elif statement, just a little different that Else statement has no condition. Example:
- a = 100
- b = 200
- if b < a:
- Print “b is smaller than a”
- Elif b == a:
- Print “b is equal to a”
- Else:
- Print “b is not smaller or equal to a”
- The seventh thing that we had learn is the AND, OR, NOT. We don’t just use it anytime that we want or else the code will be error. This is the table that my teacher, Cindy had made for us to understand it more clearly and I will share it with you because it is not easy for me to explain it to you. If you don’t understand it, this is the new topic that you have do study on your own. Sorry!
AND | OR | NOT | |
Example | X and Y | X or Y | Not X |
Explanation | True only if both X and Y are true | True if either X or Y is true | Flips the value of X |
- The eighth thing that we had learned is the For loop. We use it to perform some actions a fixed number of times. Example:
- fruits = [‘banana’, ‘apple’, ‘mango’]
for fruit in fruits:
print ‘Current fruit :’, fruit - The output will be
- Current fruit : banana
Current fruit : apple
Current fruit : mango - The ninth thing that we had learned is the Break statement. We use this to stop the code when once the condition is true. Example:
- fruits = [“apple”, “banana”, “cherry”]
- for x in fruits:
- print(x)
- if x == “banana”:
- break
- The output will be
- Apple
- Banana
- It is will stop at the banana because the condition is true and we have to break(stop).
- The tenth thing that we had learned is the Continue statement. It is the similar to the Break statement, but it is use to skip something when the condition is true. Example:
- fruits = [“apple”, “banana”, “cherry”]
- for x in fruits:
- print(x)
- if x == “banana”:
- continue
- The output will be
- Apple
- Cherry because the condition is true, so it’s going to skip the banana.
- The eleventh thing that we had learned is the range function and we use it to count number. Example:
- for x in range(5):
- print(x)
- The output will be
- 0
- 1
- 2
- 3
- 4 because it tells to count up to five number and most computer start counting from 0. So, to tell the program to start counting from any number, we have to add something. Example:
- for x in range(2, 5):
- print(x)
- The output will be
- 2
- 3
- 4.
- The twelfth thing that we had learned is the While loop and we use it to perform something while something is happening. It will repeat forever until the condition become True. Example:
- count = 0
while (count < 9):
print ‘The count is:’, count
count = count + 1 - The thirteenth thing that we had learned is Infinite Loop and it will the code to go forever because there’s no condition. Example:
- i = 1
- while i < 6:
- print(i)
- The output will just be
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1 forever because there is no condition, but if there is any condition it will become the While loop.
- That’s all the thing that we had learned. I hope you heard something new. Thank You!