분류 전체보기155 ddazua | 22강 함수와 메소드 이론 함수 : 어떠한 영역에도 갇혀있지 않고 선언된 것 -c언어 쓰임 메소드 : 어떠한 영역 안에 갇혀서 선언된 것 -자바에서 쓰임 f{x} = 2x+1 g(z) = 3z*9 print() input() 이름뒤에 소괄호가 있는 것이 함수다. 단 키워드()는 함수가 아니다. 키워드() -if() -while() -for() 함수 f (x) = 2x+1 이름 매개변수 리턴값 함수에 리턴이 있으면 사용한 부분 통째로를 리턴값으로 보자 함수의 선언 def (1)메소드명((2)매개변수,...): (3)실행할문장 (4)return 리턴값 (1)동사로 작성한다 (연필(매개변수)을 쓴다(함수)) (2)외부에서 값을 전달받기 위해서는 반드시 선언되어야 하며, 생략이 가능하다. (3)생략 가능하다. (4)생략 가능하다. 메소드.. 2021. 10. 4. 8일차 수업 | class StudentClass.py class Student: name = '' studentYear = 0 studentGroup = 0 studentNumber= 0 def setStudent_info(self, name, sYear, sGroup, sNum): self.name = name self.studentYear = sYear self.studentGroup = sGroup self.studentNumber = sNum def showStudent_info(self): print('') print(f'이름:{self.name}') print(f'학년:{self.studentYear}') print(f'반:{self.studentGroup}') print(f'번호:{self.studentNumber}.. 2021. 10. 4. 7일차 수업 | 사용자 함수~모듈 functionEx.py # 함수(function) # def 함수명(매개변수): # 함수 동작 소스코드 # return 반환데이터 def welcome(): print('Hello python') print('Nice to meet you') welcome() welcome() welcome() welcome() welcome() def make(material, count): bingsu = material + '빙수 ' print(bingsu) return bingsu + str(count) + '인분' print(make('딸기', 10)) print(make('인절미', 50)) #가변매개변수 def show(*args): print(type(args)) for item in args: prin.. 2021. 10. 4. 응용예제 | section6, 7 보호되어 있는 글 입니다. 2021. 9. 28. 이전 1 ··· 26 27 28 29 30 31 32 ··· 39 다음