commit 30ef4cfbc7b664094663e068530e275515dc5263 Author: 김민구 Date: Mon Apr 26 16:58:27 2021 +0900 1. 숫자형 2. 문자열 ex) 혼자 그냥 해본거 diff --git a/1. Number.py b/1. Number.py new file mode 100644 index 0000000..fb500d3 --- /dev/null +++ b/1. Number.py @@ -0,0 +1,29 @@ +# 덧셈 +print(4 + 7.0) + +# 뺼셈 +print(2.0 - 4) + +# 곱셈 +print(5.0 * 3.0) + +# 나머지 +print(7.0 % 3.0) + +# 나눗셈(몫) +print(7.0 / 3.0) + +# 거듭제곱 +print(2.0 ** 3.0) + +# floor division (버릴 나눗셈) +print(7 // 2) + +# 버리고 소수형으로 표현 +print(7.0 // 2) + +# round (반올림) +print(round(3.1415926535)) + +# round (원하는 소수 자리에서 반올림) +print(round(3.1415926535, 2)) \ No newline at end of file diff --git a/2. String.py b/2. String.py new file mode 100644 index 0000000..a1c09b2 --- /dev/null +++ b/2. String.py @@ -0,0 +1,38 @@ +print("hello""\n" * 3) +print("'응답하라 1988'은 많은 시청자들에게 사랑을 받은 드라마예요." + "\n" + '데카르트는 "나는 생각한다. 고로 존재한다."라고 말했다.') +print("'응답하라 1988'은 많은 시청자들에게 사랑을 받은 드라마예요." + "\n" + "데카르트는 \"나는 생각한다. 고로 존재한다.\"라고 말했다.") +print("영화 '신세계'에서 \"드루와~\"라는 대사가 유행했다.") + +year = 2021 +month = 4 +day = 2 + +# 앞에 0 표시 +print("오늘은 {}년 {:02d}월 {:02d}일입니다.".format(year, month, day)) + +# 0, 1, 2 +print("저는 {1}, {2}, {0}를 좋아합니다.".format("박지성", "유재석", "빌게이츠")) + +num_1 = 1 +num_2 = 3 +print("{0} 나누기 {1}은 {2}".format(num_1, num_2, num_1 / num_2)) +print("{0} 나누기 {1}은 {2:.2f}".format(num_1, num_2, num_1 / num_2)) +print("{0} 나누기 {1}은 {2:.0f}".format(num_1, num_2, num_1 / num_2)) +print("{0} 나누기 {1}은 {2}입니다.".format(num_1, num_2, round(num_1 / num_2, 2))) +print(f"{num_1} 나누기 {num_2}은 {num_1 / num_2}입니다.") +print(f"{num_1} 나누기 {num_2}은 {round(num_1 / num_2, 2)}입니다.") + +wage = 5 # 시급 (1시간에 5달러) +exchange_rate = 1142.16 # 환율 (1달러에 1142.16원) + +# "1시간에 5달러 벌었습니다." 출력 +print("{}시간에 {}{} 벌었습니다.".format(1, wage * 1, "달러")) + +# "5시간에 25달러 벌었습니다." 출력 +print("{}시간에 {}{} 벌었습니다.".format(wage, wage * wage, "달러")) # 코드를 채워 넣으세요. + +# "1시간에 5710.8원 벌었습니다." 출력 +print("{}시간에 {}{} 벌었습니다.".format(1, exchange_rate * wage, "원")) # 코드를 채워 넣으세요. + +# "5시간에 28554.0원 벌었습니다." 출력 +print("{}시간에 {:.01f}{} 벌었습니다.".format(wage, exchange_rate * wage ** 2, "원")) # 코드를 채워 넣으세요. \ No newline at end of file diff --git a/ex) Test.py b/ex) Test.py new file mode 100644 index 0000000..22708a4 --- /dev/null +++ b/ex) Test.py @@ -0,0 +1,31 @@ +print("goodbye world!") + +# 와우 언빌리버블 +for i in range(3): print(12) + +# 함수 +def hello(name): + print("""Hello! +Welcome to Codeit""" + name) + +# 함수 호출 +hello("chris") +hello("zz") +hello("hell") + +# 함수 +def print_sum(a, b): + print(a + b) + print(a - b) + print(a * b) + print(a / b) + +# 함수 호출 +print_sum(10, 2) + +# 형변환 +a = int(10); +b = int(3); + +print(a * b); +print(10 * 3); diff --git a/main.py b/main.py new file mode 100644 index 0000000..5596b44 --- /dev/null +++ b/main.py @@ -0,0 +1,16 @@ +# This is a sample Python script. + +# Press Shift+F10 to execute it or replace it with your code. +# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. + + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('PyCharm') + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/