범위 ¶
- Ch. 4
- 4.1. if Statements
- 4.2. for Statements
- 4.3. The range() Function
- 4.4. break and continue Statements, and else Clauses on Loops
- 4.5. pass Statements
- 4.6. Defining Functions
- 4.7. More on Defining Functions
- 4.8. Intermezzo: Coding Style
- 4.1. if Statements
가장 기억에 남는 부분 ¶
- 박희정: 전반적으로 싱기방기.
- 원준연: arguments 관련해서 기능이 굉장히 많아서 편리한 언어라고 느낌.
- 이원준: for / else가 너무 강렬했다.
- 조영준: function 호출할 때 기본값이 있거나, 어느 인자에 넣을 것인지 명시하는게 신기했음.
범위 ¶
- 5. Data Structures
- 5.1. More on Lists
- 5.2. The del statement
- 5.3. Tuples and Sequences
- 5.4. Sets
- 5.5. Dictionaries
- 5.6. Looping Techniques
- 5.7. More on Conditions
- 5.8. Comparing Sequences and Other Types
- 5.1. More on Lists
가장 기억에 남는 부분 ¶
- 조영준: import를 하지 않고 다양한 data structures를 사용할 수 있다는게 신기. python의 정신(?)이 돋보인다고 해야 하나.
- 이원준: List Comprehensions과 unpacking이 신기하고 짜증
- 원준연: iterater가 생각보다 다양하고, 다양한 만큼 하나하나가 깐깐? 하다 느낌
- 박희정: 개발자 편의가 물신물신 느껴짐.
범위 ¶
- 6. Modules
- 6.1. More on Modules
- 6.2. Standard Modules
- 6.3. The dir() Function
- 6.4. Packages
- 6.1. More on Modules
- 7. Input and Output
- 7.1. Fancier Output Formatting
- 7.1. Fancier Output Formatting
실험 ¶
import sys dir(sys) #를 심심해서 했는데 stderr를 발견. sys.stderr = open('error.txt', 'w') #이 다음부터 발생한 error는 콘솔에 출력되지 않고 파일로 기록됨 #stderr, stdout, stdin 등등도 가능.
조영준 ¶
open("result.txt","w").write(open("source.txt").readline()[::-1])
#skywave import sys #set size if len(sys.argv) == 1: ySize = 3 xSize = 3 elif len(sys.argv) == 3: ySize, xSize = [int(x) for x in sys.argv[1:]] else: print("wrong argument number(s) (arg(s) with 0 or 2 length is allowed)") exit() if min(xSize, ySize) < 1: print("wrong list size - size should be positive") exit() totalSize = ySize * xSize #get input userInput = [int(x) for x in input("type {0} numbers:".format(totalSize)).split()] if len(userInput) != totalSize: print("wrong number of items ({0} instead of {1})".format(len(userInput), totalSize)) exit() #find max intList = [] for i in range(int(len(userInput) / xSize)): intList.append(userInput[i * xSize:(i + 1) * xSize]) intList[-1].append(max(intList[-1])) intList.append([]) for i in range(xSize + 1): intList[-1].append(max([x[i] for x in intList[:-1]])) #print print(intList)
안미리 ¶
f1 = open('source.txt','r') f2 = open('result.txt','w') string = f1.read() size = len(string) nstring = string[size::-1] f2.write(nstring) f1.close() f2.close()
nums1 = [0,0,0,0] nums2 = [0,0,0,0] nums3 = [0,0,0,0] for i in range(0,3) : number = input() nums1[i] = int(number) for i in range(0,3) : number = input() nums2[i] = int(number) for i in range(0,3) : number = input() nums3[i] = int(number) for i in range(0,3) : bignum = nums1[0] if nums1[i]>bignum: bignum = nums1[i] nums1[3] = bignum for i in range(0,3) : bignum = nums2[0] if nums2[i]>bignum : bignum = nums2[i] nums2[3] = bignum for i in range(0,3) : bignum = nums3[0] if nums3[i]>bignum : bignum = nums3[i] nums3[3] = bignum square = [nums1,nums2,nums3,[0,0,0,0]] for i in range(0,4) : bignum = square[0][i] for j in range(0,4) : if square[j][i]>bignum : bignum = square[j][i] square[3][i] = bignum for i in range(0,4) : for j in range(0,4) : bignum = square[0][0] if square[i][j]>bignum : bignum = square[i][j] square[3][3] = bignum for i in range(0,4) : print(square[i][0],square[i][1],square[i][2],square[i][3])
박희정 ¶
source = open('source.txt', 'r') result = open('result.txt', 'w') for line in source: result.write(line[::-1]) source.close() result.close()
size = 3 result = [] for i in range(0, size): tempList = [] for j in range(0, size): tempList.append(input("result: ")) tempList.append(max(tempList)) result.append(tempList) lastList = [] for i in range(0, size): tempList = [] for j in range(0, size): tempList.append(result[j][i]) lastList.append(max(tempList)) lastList.append(max(lastList)) result.append(lastList) print(result)
이원준 ¶
matrix = [] for i in range(3): row_max = 0 row = [] for j in input().split(" "): inputed_number = int(j) row.append(inputed_number) row.append(max(row)) matrix.append(row) row = [] for i in range(4): row.append(max(matrix[j][i] for j in range(3))) row[-1] = max(row) matrix.append(row) for row in matrix: print(row)
범위 ¶
- 9.1. A Word About Names and Objects
- 9.2. Python Scopes and Namespaces
- 9.2.1. Scopes and Namespaces Example
- 9.2.1. Scopes and Namespaces Example
- 9.3. A First Look at Classes
- 9.3.1. Class Definition Syntax
- 9.3.2. Class Objects
- 9.3.3. Instance Objects
- 9.3.4. Method Objects
- 9.3.5. Class and Instance Variables
- 9.3.1. Class Definition Syntax
범위 ¶
- 2.9.4. Random Remarks
- 2.9.5. Inheritance
- 2.9.5.1. Multiple Inheritance
- 2.9.5.1. Multiple Inheritance
- 2.9.6. Private Variables
- 2.9.7. Odds and Ends
- 2.9.8. Exceptions Are Classes Too
- 2.9.9. Iterators
- 2.9.10. Generators
- 2.9.11. Generator Expressions