공부라고하지만
파이썬 _230809
sohhere
2023. 8. 9. 22:43
# 가장 기본적인 output함수
# 기본 출력, 의도한 출력값
# seperator , end 옵션 사용
# excape code 사용방법
#task runner ctrl + shift +b
#print 함수는 출력하고자 하는 변수, 혹은 문자, 자료형을 출력
#print(""" hello python """)
#print() 입력값을 넣지 않을 경우 줄바꿈
#Separator 옵션
print('T','E','S','T', sep='')
#sep 옵션 사용 시 '' 공백을 제거하여 출력
print('2021','10','29',sep='-')
#글자 사이에 - 를 추가하여 출력
print('niceman','google.com',sep='@')
#end 옵션 사용
print('welcome to',end='') #끝을 다음 문장과 연결 !
print('the paradise',end = ' ')
#format 사용 [] , {} , ()
print('{} and {}'.format('you','me'))
print('{0} and {1} , and {0}'.format('you','me'))
print('{a} and {b}'.format(a='you',b='me'))
# 순서 사용 가능
#format을 안쓰고 사용가능
#%()
# 데이터 타입 선언
# Bytes , Lists , Tuples, Sets , Dictionaries
# 데이터 타입
v_str1 = "Niceman"
v_bool = True
v_float = 10.3
v_int = 7
v_dict = {
"name" : "kim",
"age" : 25
}
v_list = [3, 5, 7]
v_tuple = 3, 5, 7
v_set = {7, 8, 9}
print(type(v_tuple))
# 숫자형 및 연산자
i1 = 39
i2 = 939
big_int1 = 9999999999999999999999999999999999999
big_int2 = 7777777777777777777777777777777777777
f1 = 1.234
f2 = 10.
# ** 제곱
print(f1 + i1)
a = 5.
b = 4
# 형변환 int , float , complex 복소수의 실수 분이랑 허수 분?
y = 100
y += 100
print(y)
# 수치 연산 함수
print(abs(-7)) # 절대값
n , m = divmod(100 , 8)
print(n , m )
import math
print(math.ceil(5.1)) # 5.1 보다 크면서 가장 작은 정수
print(math.floor(3.11))
# 문자열 연산
# 문자열의 길이 = len 함수 공백도 한글자로 치게됨!
str1 = "hello world"
print(len(str1))
escape_str1 = "Do you have a \"big collection\""
print(escape_str1)
print("Tab\tTab\tTab")
# \t 탭으로 적용
# Raw String
raw_s1 = r'C:\Programs\Test\Bin'
# r의 경우 escape 적용이 되지 않는다!
print(raw_s1)
# 멀티라인
multi = \
"""
문자 열
멀티라인 테스트
"""
print(multi)
# 변수 선언 후 \ 역슬래시는 다음 문장이 이어진다는 것을 의미하기 때문에 오류 없이 출력!
# 문자열 연산 가능 = 문자열 , 문자열만 가능
str_o4 = "Nice man"
print('a' in str_o4)
print('f' in str_o4)
print('f' not in str_o4) # 문자열 안에 f가 없는 것 유무!
# 문자열 함수
a = "niceMan"
print(a.replace('nice','good'))
# ctrl + / 주석
d = "helloWorld"
print(d[0:len(d)])
# a[:] 전체가 다 출력
# a[: len(a)] 처음부터 전체다 출력
자료형 파트 젤 지겨워,,,