1๏ธโฃ Data type
2๏ธโฃ ์ฐ์ฐ์
3๏ธโฃ String ์๊ธฐ
string1 = "hello" string2 = "12345" string3 = "์๋ " print(type(string1)) #<class 'str'> print(type(string2)) #<class 'str'> print(type(string3)) #<class 'str'>
integer1 = 12356 integer2 = 1234567890 print(type(integer1)) #<class 'int'> print(type(integer2)) #<class 'int'>
float1 = 2.25 float2 = 3.33 print(type(float1)) #<class 'float'> print(type(float2)) #<class 'float'>
complex_number1 = 1+3j complex_number2 = 2+6j print(type(complex_number1)) #<class 'complex'> print(type(complex_number2)) #<class 'complex'> ``` >
1 == 1 # True 2 == 3 # False 3 == "3" # False (Data type์ด ํ๋ฆฌ๊ธฐ ๋๋ฌธ) print(type(True)) #<class 'bool'>
num1 = 3 num2 = 5 num1 + num2 #8
num1 = 6 num2 = 4 num1 - num2 #2
num1 = 5 num2 = 3 num1 * num2 #15
num1 = 15 num2 = 3 num1 / num2 #5
- String concatenation์ ๋ฌธ์์ ๋ณ์๋ก ์ ์ธ๋ ๋ฌธ์๋ฅผ ํฉํ ๋ ์ฃผ๋ก ์ฌ์ฉ๋๋ค.
print("Hello, " + "world!") #Hello, world!
- String์ด ๋ณ์๋ก ์ ์ธ๋์ด ์์ ๋ ๋ฌธ์์ด๊ณผ ๋ณ์์ ๊ฐ์ ๋ํ๋ ๋ฐฉ๋ฒ์ด๋ฉฐ, ๊ธธ๊ณ ๋ณต์กํ ๋ฌธ์์ด์ผ ๊ฒฝ์ฐ ์ฃผ๋ก ์ฌ์ฉ๋๋ค.
โ๏ธ ์ฃผ์์ฌํญโ๏ธ
- ๋จผ์ ๋ฐ์ดํ ์์ f ๋ฅผ ๋ถ์ฌ์ผ ํจ.
- ์นํ ํ๊ณ ์ถ์ ๋ณ์ (ํน์ ๋ณ์๊ฐ ์๋์ด๋ ๋จ. ์๋ฅผ ๋ค์ด ํจ์ ํธ์ถ์ด ๋ ์๋ ์์ต๋๋ค) ๋ฅผ {}๋ฅผ ์ฌ์ฉํด์ ํ์ํฉ๋๋ค.
name = "Drageon" print(f"Hello! {name}")
Python์ ์์ํ๋ฉฐ python์ ๋ค๋ฃจ๋๋ฐ ์ฃผ์ํด์ผํ ๋ถ๋ถ๋ค์ ํ์ธํ์๋ค. ์์ ๋ด์ฉ๋ค์ ๊ธฐ๋ณธ์ผ๋ก, ์์ผ๋ก python๊ณผ ํจ๊ป ํ๋๋ฐ ๊ฐ์ฅ ๋น๋ฒํ๊ฒ ์ฌ์ฉ๋ ๊ฒ์ด๋ค.