บทความ

Week 5

This week is about recursion. Recursion is simply a process of defining a problem in terms of (a simpler version of) the problem itself. Recursion including the process case and a base case. A base case is a end case which would stop the recursion loop. For instance, eating a rice, if rice is empty then stop. So today we receive assignment about drawing tree figure. First, we need to make a tree's core, with a straight line. Next, make it separate into 2 branches, so let make it to the left first. (core - - left branch 1) Then we make a recursion, so we gotta make it all left, it should look like this. (core - - left branch 1 - - left branch 2 - - left branch 3) Next, when it comes at the end or leaves, so we make the right ones. core - - left branch 1 - - left branch 2 - - left branch 3 - - right branch 3) Then the recursion will be traced back at 'left branch 2' to make right ones. core - - left branch 1 - - left branch 2 - - right branch 2 - - left branch ...

Week 4

This week is about python lists. A Python list is a collection of arbitrary objects, somewhat similar to an array in many other programming languages but more flexible. A list can be viewed as comma-separated items between square brackets. Each item occupies one slot in the list. Each slot has a number associated to it. This number is called index. Index is used to refer to item in the slot. List index is an integer starting from 0 to list size – 1. Python allows negative index where index - 1 refers to the right most item. Operations + concatenation (same as in string) * repetition (same as in string) len(L) number of items in list L x in L membership –check whether x is in list L for x in L : iteration through every item in list L Functions Common functions include 1 list.append(obj) Appends object obj to list 2 list.count(obj) Returns count of how many times obj occurs in list 3 list.extend(seq) Appends the contents of seq to list 4 list.index(obj) Returns t...

Week 3

This week we learn about running time. Running time is to measure the number of steps the program executes and input size. And above all, we have a worst case called Big-O notation, which called an asymptotic upper bound. This lab week is about to find running time in provided examples. For instance: ALGORITHM m01 is Operation : simple loop Input : an integer, n Output : SET rounds to 0 SET sum to 0 WHILE rounds is less than n  increment sum by 1  increment rounds by 1 ENDWHILE RETURN sum From above we know that SET rounds to 0; SET sum to 0; is constant, so we make that called constant 'c' and for while function we have to put 1st degree of variable, so we make it called variable 'x'. Then, we have to look conditions in while function that said 'round is less than n', so we can know that it should take n steps to make out of while loop and when is pass the condition, it'll re-loop again till not match the conditions. So, we could make it ru...

Week 2

This week we learn about Turtle Graphic and OOP. Object-oriented programming is a programming paradigm that revolves around object. Principles of OOP    1. Encapsulation    2. Inheritance.    3. Polymorphism Encapsulation Class : a blueprint for how to build a certain type of object. Class describes attributes and behavior of objects instantiated from the class. Python uses the keyword class to define a class. Object : an instance of a class Constructor : a special that creates an instance of the class. Constructor initializes values of attributes of an object. In Python, constructor of a class is defined as __init__. Inheritance Inheritance is the ability to define a new class that is an extension of an existing class. The new class (derived class) inherits all of the methods of the existing class (base class). Example : Person class (base class), Employee class (derived class) and Boss class (derived class). The example shows ...

Week 1

This 1st week is all about new experience and knowledge, we learn how to make algorithm about Roman and Arabic number. Then, after we know about algorithm, we have to code in python. We must know value of each Roman's alphabet. So, basically I  equal to 1 V equal to 5 X equal to 10 L equal to 50 C equal to 100 And, when know about Roman number then we can convert from Arabic to Roman number or Roman to Arabic number. For Roman number, when a front alphabet is higher than next to it, it's mean plus(e.g. XI equal to 10 + 1 = 11). And in contrast, when a front alphabet is lower than next to it, it's mean minus(e.g. IX equal to 10 - 1 = 9). And when we encounter a complicate one, it's should look like this. XXII equal to 22.