Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Discussion - Python Chap 11 컴퓨터의 개념 및 실습 5월 25일 Intelligent Data Systems Lab. Department of Computer Science & Engineering Discussion 11-1 Explain, with examples, the following properties of Python lists; 1. dynamic 2. heterogeneous 3. mutable What about Python strings? 컴퓨터의 개념 및 실습 Discussion 11-2 What does the following statement do? data.sort(key=use_gpa) What type should the input parameter of the function use_gpa take? 컴퓨터의 개념 및 실습 Discussion 11-3 What are the benefits of using lists for managing the pips in the dice (DieView)? onTable = [ [], [3], [2,4], [2,3,4], [0,2,4,6], [0,2,3,4,6], [0,1,2,4,5,6] ] for pip in self.pips: pip.setFill(self.background) on = onTable[value] for i in on: self.pips[i].setFill(self.foreground) 컴퓨터의 개념 및 실습 # turn correct pips on if value == 1: self.pip4.setFill(self.foreground) elif value == 2: self.pip1.setFill(self.foreground) self.pip7.setFill(self.foreground) elif value == 3: self.pip1.setFill(self.foreground) self.pip7.setFill(self.foreground) self.pip4.setFill(self.foreground) elif value == 4: self.pip1.setFill(self.foreground) self.pip3.setFill(self.foreground) self.pip5.setFill(self.foreground) self.pip7.setFill(self.foreground) elif value == 5: self.pip1.setFill(self.foreground) self.pip3.setFill(self.foreground) self.pip4.setFill(self.foreground) self.pip5.setFill(self.foreground) self.pip7.setFill(self.foreground) else: self.pip1.setFill(self.foreground) self.pip2.setFill(self.foreground) self.pip3.setFill(self.foreground) self.pip5.setFill(self.foreground) self.pip6.setFill(self.foreground) self.pip7.setFill(self.foreground) 컴퓨터의 개념 및 실습 Chapter 10 - 5 Discussion 11-4 How would you represent and manipulate a two dimensional matrix of size 2 X 3? >>> A = [ [2, 1], [-4, 3], [2, -2] ] >>> A [[2, 1], [-4, 3], [2, -2]] >>> A[1] [-4, 3] >>> A[1, 1] >>> A[1][1] 3 >>> for i in range(3): for j in range(2): print(A[i][j], end=' ') 2 1 -4 3 2 -2 >>> for row in A: for e in row: print(A[i][j], end=' ') Traceback (most recent call last): File "<pyshell#54>", line 1, in <module> A[1,1] TypeError: list indices must be integers, not tuple 컴퓨터의 개념 및 실습 Discussion 11-5 How would you two matrices of size 2 X 3? >>> A = [ [2, 1], [-4, 3], [2, -2] ] >>> B = [ [0, 2], [1, -3], [3, -2] ] >>> C[0] = A[0] Traceback (most recent call last): File "<pyshell#60>", line 1, in <module> C[0] = A[0] NameError: name 'C' is not defined >>> C = [ [0, 0], [0, 0], [0, 0] ] >>> for i in range(3): for j in range(2): C[i][j] = A[i][j]+B[i][j] >>> C [[2, 3], [-3, 0], [5, -4]] 컴퓨터의 개념 및 실습