본문 바로가기
카테고리 없음

codeit강의_02.숫자형으로 할수있는 연산

by 오르락내리락반복하는 인생 2023. 8. 22.
반응형

02.숫자형으로 할 수 있는 연산
#floor division (버림 나눗셈//나눈값에서 소수점을 버린다)
#a, b 둘 중 하나가 소수형이면 .0 으로 나온다
print(7 // 2) 
print(8 // 3)
print(8.0 // 3)
#round (반올림)
print(round(3.14234543, 4))

 

3
2
2.0
3.1423

 

03. 문자형(String)

# 문자열(String) : 키보드로 쓸수있는 문자열
#'코드잇' 작은 따옴표, "코드잇" 큰 따옴표를 앞뒤로 쓴다
# 문자열 연산
# 7(숫자로 인지)+6 ->13 , 덧셈: 문자열 연결(string concatenation)
# "Hello" + "World" -> "HelloWorld"
# "Hello" 3(문자열 3번 반복) -> "Hello" + "Hello" + "Hello"-> "HelloHelloHello"

print("코드잇")
print("유재석")
print('I'm excited to learn Phython!'')->syntax error
I 를 문자열 인식, 나머지부분 문자로 인식 못함
print("I"'m excited to learn Phython!")
print("I'm "excited" to learn Phython!") ->문자열에 큰따옴표 작은따옴표 같이 있으면?
#따옴표 마다 앞에 역슬래쉬 써줘야한다

 

print("I\'m \"excited\" to learn Phython!")

 

I'm "excited" to learn Phython!

댓글