반응형
-
[파이썬]while, for 반복문 탈출과 계속하기 - break, continue 이번 포스팅에서는 while과 for 같은 반복문에서 조건문이 True인 경우에도 반복문을 탈출할 수 있게 해주는 break와 반복문의 시작 지점으로 돌아가게 해주는 continue에 대해 알아본다. 반복문 강제로 탈출하기 - break break로 반복문 강제로 탈출하기 while문의 조건문이 True일 경우에도 break로 while문을 빠져나올 수 있다. count = 0 while True: count += 1 print('현재 카운트 %d' %count) if count == 5: break print('while문 탈출') #결과 출력 현재 카운트 1 현재 카운트 2 현재 카운트 3 현재 카운트 4 현재 카운트 5 while문 탈출 위 예문을 보면 조건문은 항상 True이기 때문에 while문..
-
8. keep up with(catch, fall) 1. 예문 - We can't keep up with all the changes. - I couldn't keep up with the rest of the class. - They're struggling to keep up with their competitors. - A: So, what's new in AI? B: I haven't really been keeping up with the latest, but not a whole lot I think. A: Maybe that's a good thing. I remember people saying that they need to slow down the development. B: They're still saying that, b..
-
[파이썬]함수 이해하기 - 함수의 기본 구조와 특성 이번 포스팅에선 함수의 기본에 대해 알아본다. 함수의 만드는 방법과 어떤 형태의 함수들이 있는지 알아보자. 함수 만들기 - 예약어 def 함수란 무엇인가 앞선 포스팅들에서 함수라는 단어가 계속 언급되었다. 함수란 무엇일까? 이미 학창 시절 수학 시간에 함수를 대해 배웠기에 함수가 무엇인지 짐작하는 건 어렵지 않다. 함수란 입력값을 넣으면 결괏값을 내주는 것을 말한다. 비유를 들자면 믹서기로 오렌지 쥬스를 만들 때, 오렌지 주스는 입력값, 오렌지 주스가 출력 값이다. 오렌지를 오렌지(input)를 넣었을 때 오렌지주스(output)를 결괏값으로 돌려주는 믹서기(function)가 함수가 되는 것이다. 만약 믹서기 함수에 오렌지가 아닌 사과를 입력해준다면 사과쥬스를 출력해줄 것이다. 돌멩이를 넣으면 믹서기 ..
-
[파이썬]딕셔너리 함수들 - keys, values, items, clear, get, in 이번 포스팅에서는 딕셔너리 관련 함수들에 대해 포스팅한다. 딕셔너리의 키 값들을 반환하는 keys, value값들을 반환하는 values, 키와 value 쌍을 반환하는 items, 딕셔너리의 모든 값을 지우는 clear, key를 통해 value를 얻는 get, 요소값이 딕셔너리에 있는지 확인하는 in 함수를 알아볼 것이다. 딕셔너리의 Key, Value 값 얻기 - keys, values, items keys 함수로 딕셔너리의 key 값 얻기 >>> dic = {'Soccer': 'Jisung Park', 'Baseball': 'Chanho Park', 'Golf': 'Seri Park'} >>> dic.keys() # 딕셔너리의 키 값들을 dict_keys 자료형으로 반환 dict_keys(['So..
-
[파이썬]VS Code와 Extensions 설치하기 Visual Studio Code 설치 https://code.visualstudio.com/ Visual Studio Code - Code Editing. Redefined Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. code.visualstudio.com 위 링크로 들어가면 아래의 화면이 나온다. 본인 컴퓨터의 운영체제에 맞게 설치 파일을 다운로드한다. 동의하고..
-
25.09.23 - Placing an order at a cafe 1. What type of coffee do you usually order at a cafe, and why? - I usally order an iced americano when I go to a cafe. I actually used to have frappuchino everytime I was at a cafe, but since I made up my mind to cut back on sugar, I haven't had frappuchino things very much. Actually I'm trying to cut back on caffeine too, but I have no other options but americano. The main reason I go to cafes.. -
6. go over 1. 예문 - Does anybody want me to go over the rules again? - I went over it in my head again and again. - A: Come on. Andrew. We've gone over this a dozen times. You can't keep acting on your own like this. B: I know, but all that does is slow everything slow. You trust my judgement, right? When have I been wrong? A: It's not about that. We're all part of a team. If something comes up, you hav..
-
[파이썬]사용자 입력과 출력 - input, print 이번 포스팅에선 사용자로부터 값을 입력받는 input 함수와 입력된 자료를 출력하는 print 함수에 대해 알아보자. 우리가 사용하는 프로그램은 대부분 미리 입력된 값이 아닌 유저로부터 실시간으로 입력값을 받고 결과를 반환해준다. 파이썬 코드상에서 값을 입력하는 게 아니라 프로그램에서 값을 입력받으려면 input 함수를 사용해야 한다. 사용자로부터 값 입력받기 - input input 함수로 입력값 받기 프롬프트에서 사용자로부터 값을 입력받으려면 input 함수를 사용하면 된다. 간단한 예시를 보자 >>> user_input = input() Cokid >>> user_input 'Cokid' input 함수는 프롬프트에 값을 입력할 수 있게 해 주고 'Cokid'를 입력하니 변수에 입력값이 저장되었다...
-
[파이썬]문자열 포매팅 - 포맷 코드, format 함수, f 포매팅 문자열 포매팅이란 문자열 안에 특정 값을 삽입하는 기법이다. 예를 들어 매일 그날의 요일을 출력하는 프로그램이 있다고 가정해보자. "It is Monday" "It is Tuesday" 위 문자열을 보면 문자열 내부에 요일을 나타내는 'Mon'과 'Tues' 부분이 매일 바뀌어야 한다. 문자열 포맷 코드로 포매팅(%d, %f, %s) 포매팅을 하는 첫 번째 방법은 문자열 포맷 코드를 사용하는 것이다. 예시를 보자. >>> a = "It is %sday." % "Mon" # 문자열 바로 대입. >>> print(a) It is Monday. >>> today = 'Tues' >>> a = "It is %sday." % today # 변수로 대입 >>> print(a) It is Tuesday. 포맷 코드를..
반응형