1. ν€μλ (keyword)
μλ―Έκ° κΈ° λΆμ¬λ λ¨μ΄
import keyword
print(keyword.kwlist)
2. μλ³μ (identifier) ꡬλΆνκΈ°
μλ³μ | μΊλ© μΌμ΄μ€ (λλ¬Έμλ‘ μμ) |
ν΄λμ€ | |
μ€λ€μ΄ν¬ μΌμ΄μ€ (μλ¬Έμλ‘ μμ) |
λ€μ κ΄νΈ O | ν¨μ | |
λ€μ κ΄νΈ X | λ³μ | ||
*μμΈ μμ |
3. μλ£ν (data type)
- λ¬Έμμ΄ (string)
- μ«μ (number) : μ μν (integer), μ€μ (floating point, λΆλ μμμ )
- λΆ (boolean) : True/False
4. λ³μ
λ³μ μ μΈ → κ° ν λΉ → μ°Έμ‘°(μ¬μ©)
5. μ¬μ©μ μ λ ₯ : input()
λͺ λ Ή ν둬ννΈμμ μ¬μ©μλ‘λΆν° λ°μ΄ν°λ₯Ό μ λ ₯λ°μ λ μ¬μ©
리ν΄κ°μ 무쑰건 λ¬Έμμ΄ μλ£ν β β β
a = input("μ
λ ₯: ")
print("μλ£: ", a)
print("μλ£ν: ", type(a))
6. μΊμ€νΈ (cast) : λ¬Έμμ΄ → μ«μ λ³ν
int() : λ¬Έμμ΄μ μ μ (int) λ‘ λ³ν
float() : λ¬Έμμ΄μ μ€μ/λΆλμμμ (float) μΌλ‘ λ³ν
a = input("μ
λ ₯1: ")
b = int(a)
c = input("μ
λ ₯2: ")
d = int(c)
print("λ¬Έμμ΄ μλ£: ", a + c)
print("μ«μ μλ£: ", b + d)
7. μ«μ → λ¬Έμμ΄ λ³ν
str() : μ«μλ₯Ό λ¬Έμμ΄λ‘ λ³ν
a = str(1234)
b = str(12.34)
print(type(a), a)
print(type(b), b)
8. format() ν¨μ
μ«μμ λ¬Έμμ΄μ λ€μν ννλ‘ μΆλ ₯ν μ μλλ‘ νλ ν¨μ
a = "{}".format(10)
b = "{}{}{}".format(10, 20, 30)
print(a, b)
-. μ°Έκ³ μλ£
7. Input and Output
There are several ways to present the output of a program; data can be printed in a human-readable form, or written to a file for future use. This chapter will discuss some of the possibilities. Fa...
docs.python.org
'π Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
νμ΄μ¬ λ΄μ₯ν¨μ enumerate()μ for λ°λ³΅λ¬Έ (0) | 2024.01.10 |
---|---|
231228 THU νμ΄μ¬ ν¨μ vs λ©μλ (0) | 2023.12.28 |
νμ΄μ¬ λ°λ³΅λ¬Έ - for, while (0) | 2023.12.28 |
231221 THU νμ΄μ¬ λ³΅μ΅ (2) CRM νμ΄λ° λΆμ (0) | 2023.12.21 |
231221 THU νμ΄μ¬ λ³΅μ΅ (1) νμ΄μ¬ λ°μ΄ν° λΆμ λ° μκ°ν κΈ°μ΄ (1) | 2023.12.21 |