22.11.18 Control Flow - For
- For 구문 꽤나 직관적이고 지금까지 당연하게 사용해왔던 For 구문. >>> myList = [1,2,3,4,5] >>> for item in myList: ... print(item) ... 1 2 3 4 5 - Pass Statement 아래와 같이 pass 사용 시 아무 일도 나타나지 않는다! >>> animalLookup = { ... 'a':['aardvark','antelope'], ... 'b':['bear'], ... 'c':['cat'], ... 'd':['dog'], ... } >>> for letter,animals in animalLookup.items(): ... pass - Continue Statement 아래와 같이 continue를 이용하여 특정 조건을 만족할 시 특정..
22.11.13 Challenge_Structuring Scribes(3)
세 개의 data set이 있다. 타입은 dictionaries. 첫 번째, [15,15]에서 시작해서 30'의 각도로 100번 이동. {'degree' : 30, 'position' : [15,15], 'instructions' : [ {'function':'forward', 'duration':100} ]} 두 번째, [0,0]에서 시작해서 145'의 각도로 10번 이동 후, 오른쪽으로 20번 이동 후, 아래로 2번 이동. {'degree' : 135, 'position' : [0,0], 'instructions' : [ {'function':'forward', 'duration':10}, {'function':'down', 'duration':2}, {'function':'right', 'durat..
22.11.12 Challenge_Structuring Scribes(2)
오늘은 정답지를 봐야겠다. 함수를 보고, 한 번 코드 돌려보고, 출제자의 의도가 무엇인지 파악하고, object를 고쳐 보아야겠다! Solution의 결과창...... canvas = Canvas(30, 30) scribes = [ #3개의 Key가 존재하는 dictionaries를 3개 정의 {'degrees': 30, 'position': [15,15], 'instructions': [ {'function':'forward', 'duration': 100} ]}, {'degrees': 135, 'position': [0, 0], 'instructions': [ {'function':'forward', 'duration': 10}, {'function':'down', 'duration': 2}, {'f..