반응형
-
[파이썬]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문..
-
4. It's not like ~ 1. 예문 - Come on. It's not like I do that every day. - What's the big deal? It's not like I cursed or anything. - I'm so worried. It's not like I can speak Chinese or have someone there. - The other day, Frank told me about this business idea he had and I just told him what I thought and now he's upset with me. It's not like I have to agree with him on everything, right? 2. 심화 - Don't worry. It's..
-
[파이썬]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 위 링크로 들어가면 아래의 화면이 나온다. 본인 컴퓨터의 운영체제에 맞게 설치 파일을 다운로드한다. 동의하고..
-
[파이썬]함수 이해하기 - 함수의 기본 구조와 특성 이번 포스팅에선 함수의 기본에 대해 알아본다. 함수의 만드는 방법과 어떤 형태의 함수들이 있는지 알아보자. 함수 만들기 - 예약어 def 함수란 무엇인가 앞선 포스팅들에서 함수라는 단어가 계속 언급되었다. 함수란 무엇일까? 이미 학창 시절 수학 시간에 함수를 대해 배웠기에 함수가 무엇인지 짐작하는 건 어렵지 않다. 함수란 입력값을 넣으면 결괏값을 내주는 것을 말한다. 비유를 들자면 믹서기로 오렌지 쥬스를 만들 때, 오렌지 주스는 입력값, 오렌지 주스가 출력 값이다. 오렌지를 오렌지(input)를 넣었을 때 오렌지주스(output)를 결괏값으로 돌려주는 믹서기(function)가 함수가 되는 것이다. 만약 믹서기 함수에 오렌지가 아닌 사과를 입력해준다면 사과쥬스를 출력해줄 것이다. 돌멩이를 넣으면 믹서기 ..
-
[파이썬]IDE 선택하기 - Visual Studio Code 파이썬 코드를 짤 때 IDE를 사용한다. IDE란 integrated Development Environment를 뜻하는데, 작성된 코드를 실행해줄 뿐만 아니라 코드의 가독성을 높여주거나 디버깅도 해준다. 파이썬에도 IDLE라는 기본 IDE가 있으나 딱히 장점이 없어 다른 IDE에서 코딩을 한다. 보통 처음 선택한 IDE를 앞으로도 계속 사용할 확률이 높기에 처음부터 자신에게 잘 맞는 IDE를 선택하는 것이 중요하다. 나는 PyCharm과 Visual Studio Code 두 IDE 사이에서 고민하다 결국 VS Code를 선택했으며 그 이류를 말해보겠다. 어떤 IDE를 사용해야 할까? 내가 파이썬을 배우고자 한 이유는 파이썬이 최근 가장 인기 있는 프로그래밍 언어로 부상했고 앞으로도 그 점유율이 더 올라..
-
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..
-
5. Otherwise 1. 예문 - It could use a new finish. Otherwise, it's in really good condition. - We should probably let everyone know we're brothers and sisters before they start thinking otherwise. - A: We should get going. Otherwise, we'll miss the beggining. You know I can't drive fast like you. B: Right. Urgh. Why did I have to hurt my leg. Otherwise, I wouldn't have you drive in the rain. A: Don't worry...
-
3. ~ 치고는 - for 1. 예문 - You're pretty good for a beginner. - You look really good for your age. - For a weekday, it was pretty crowded. - Well, for a stray, she looks to be in fairly good condtion. I'd put her somewhere around 4 months old. - For someone who doesn't own a dog, you seem to be comfortable handling her. 2. 심화 - It's not that bad for a ten-thousand-won pizza. - It's a pretty price for an appartmen..
-
[파이썬]1부터 1000까지 각 숫자의 개수 세기 오늘은 코딩 도장에서 많은 추천수를 받은 문제인 1부터 1000까지의 숫자에서 등장하는 숫자들의 개수를 세는 문제를 풀어보자. 각 숫자의 개수 구하기 우선 예시를 보자. 만약 1부터 20까지의 숫자들에서 나오는 숫자들의 개수를 구해보자. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 → 0: 2개, 1: 12개, 2: 3개, 3: 2개, 4: 2개, 5: 2개, 6: 2개, 7: 2개, 8: 2개, 9: 2개 155에는 1이 1개, 5가 2개 있는 셈이다. 각 숫자들이 나오는 횟수을 합해보자. for 반복문 단순하고 간단하게 풀어봤다. nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for i in range(1, 1001): for j i..
반응형