Guidelines

νŒŒμ΄μ¬μ—μ„œ 숫자λ₯Ό λ‹€λ£¨λŠ” 법

νŒŒμ΄μ¬μ—μ„œ 숫자 ν˜•νƒœμ˜ 데이터λ₯Ό λ‹€λ£¨λŠ” 2가지 μžλ£Œν˜•μ€ μ •μˆ˜ν˜•(int)κ³Ό μ‹€μˆ˜ν˜•(float)μž…λ‹ˆλ‹€.


μ •μˆ˜ν˜• (Integer Type)

μ •μˆ˜ν˜•μ€ -2, 0, 10κ³Ό 같이 μ†Œμˆ˜μ μ΄ μ—†λŠ” 숫자λ₯Ό λœ»ν•©λ‹ˆλ‹€.

νŒŒμ΄μ¬μ—μ„œ μ •μˆ˜ν˜•μ€ int둜 ν‘œν˜„ν•©λ‹ˆλ‹€.

μ •μˆ˜ν˜• μ˜ˆμ‹œ
age = 25 initial_value = 0 print(type(age)) # <class 'int'>

μ‹€μˆ˜ν˜• (Floating-Point Type)

μ‹€μˆ˜ν˜•μ€ 3.14, -2.1κ³Ό 같이 μ†Œμˆ˜μ μ„ ν¬ν•¨ν•˜λŠ” 숫자λ₯Ό λœ»ν•©λ‹ˆλ‹€.

νŒŒμ΄μ¬μ—μ„œ μ‹€μˆ˜ μžλ£Œν˜•μ€ float둜 ν‘œν˜„ν•©λ‹ˆλ‹€.

μ‹€μˆ˜ν˜• μ˜ˆμ‹œ
temperature = 36.5 price = 19.99 print(type(temperature)) # <class 'float'>

μ •μˆ˜ν˜• μžλ£Œν˜•κ³Ό μ‹€μˆ˜ν˜• μžλ£Œν˜•μ„ 더할 경우, κ²°κ³ΌλŠ” μ‹€μˆ˜ν˜•μœΌλ‘œ λ°˜ν™˜λ©λ‹ˆλ‹€.

μ •μˆ˜ν˜•κ³Ό μ‹€μˆ˜ν˜• λ”ν•˜κΈ°
result = 10 + 3.5 print(result) # 13.5 print(type(result)) # <class 'float'>
Mission
0 / 1

μ •μˆ˜ν˜•κ³Ό μ‹€μˆ˜ν˜• λ³€μˆ˜λ₯Ό μ‚¬μš©ν•˜μ—¬ κ²°κ³Όλ₯Ό 좜λ ₯ν•˜μ„Έμš”. κΈ°λŒ€λ˜λŠ” 좜λ ₯은 45.0μž…λ‹ˆλ‹€.

a = 15

b = 30.0

result = a + 

print(result)

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result