Function2 python 2일차 / function / def / parameters / arguments / return values / format / f"" # 2.4 Functions # function 을 정의할 때 def 를 쓴다. # 변수와 마찬가지로 숫자로 시작하면 안되고 스네이크 케이스를 쓴다 def say_hello(user_name, user_age): # parameter print("hello", user_name, "how r u ?") print("you are", user_age, "years old.") # 2.5 Identation # python에선 공백이 매우 중요하다. # 코드를 두칸 띄워줘야 그 코드가 어떤것 안에 들어가 있는걸 알수있다. def say_bye(): print("bye~") say_bye() # 2.6 Parameters # parameter: function의 괄호 안에서 쓰는 인자 # argument: f.. 2023. 1. 2. [Javascript] Named Export / export default js파일에서 데이터나 함수를 외부파일에서 사용할때 export 로 내보내줘야한다. export 와 export default 로 작성 되어있는 샘플을 흔히 볼 수 있는데 그 차이를 알아보려고 한다. export default : 기본 export 내보내는 JS파일에서 function 이름은 생략이 가능하다. 한가지 함수만 작성할 수 있다. 가져오는 JS파일에서 import 함수명 부분은 다른 이름으로 변경해도 상관없다. // getRandom.js export default function () { return Math.floor(Math.random() * 10) } // main.js import getRandom from './getRandom' export : named export 내보내는 JS.. 2021. 10. 29. 이전 1 다음 반응형