변수 선언, print로 출력하기,숫자
2022. 3. 12. 20:32ㆍPython 정리/Python의 기본
변수 선언
num = 1
name = '1'
new_num = int(name)
print(new_num, type(new_num))
print 출력
print('hi')
#구분
print('Hi', 'Mike')
#Hi Mike
#space 가 아닌 다른 문자로 구분 짓고 싶을 때
print('Hi','Mike',sep=',')
#Hi,Mike
#end 정의 주로 \n(줄바꿈이 들어감)
print('Hi','Mike',sep=',', end='\n')
print('Hi','Mike',sep=',', end='\n')
#Hi,Mike
#Hi,Mike
print('Hi','Mike',sep=',', end='.\n')
#Hi,Mike.
숫자
#수학 함수
import math
result = math.sqrt(25)
print(result)
#5.0
y = math.log2(10) #밑이 2임
print(y)
#3.32192......
#math에 어떤 함수가 있는지 알고 싶을때는 document를 보면 된다
print(help(math))
'Python 정리 > Python의 기본' 카테고리의 다른 글
Import 문과 AS (0) | 2022.05.08 |
---|---|
클래스의 초기화와 클래스 변수 (0) | 2022.05.07 |
예외 처리 (0) | 2022.05.07 |
문자열 메소드,문자의 대입<.format()>,f-strings (0) | 2022.03.14 |
문자열 : """ 몇개의 줄""", 리테럴 응용 (0) | 2022.03.12 |