2015년 2월 15일 일요일
CSC148 Week 6 Slog
In this week in the lecture, we learned about Object-Oriented Programming. When I first see the lecture slides, I was really confused because it looked like biology to me. There were terms called 'tree', 'leaf', and 'node'. As the lecture goes, I understood that the Object-Oriented Programming was like family tree. Parent is top of the tree which is node and children are below parents and children who doesn't have children is called leaf. To write codes for this programming, as I see lots of codes with Tree class, all of them had same __init__ method. For other methods, we can write recursion codes or other codes that we learned throughout the lectures. These are concepts of Object-Oriented Programming.
2015년 2월 7일 토요일
CSC148 Week5 Slog
Throughout the week 4 in the lecture, we learned about recursion in the class. From what I learned, recursion is a function in a function. It means that for example, if the function is called count_list(L), then inside that function there is also function called count_list but the variable inside is different like x. To write that we have to write 'for x in L' then write count_list(x). For the recursion, else part is important because when the function inside the function reaches the end, it goes to else part and get value from the else part.
Tracing the recursion function was easy after I knew how to do it. It was just following what the function said. For most of the recursion, there are isinstance(L, list) and else part. If the L part to put in the function was a list, then I go to isinstance part and follow it then at the end, there is a recursion function. It is like go inside the L and if the x in L is list then go to isinstance part again. If not, then go to else then change value inside to what else says. Then if it says sum, sum them up. It was hard for me at first, but after I practiced it at home, I understood how the recursion worked.
피드 구독하기:
덧글 (Atom)