본문 바로가기
First step/AI 기초반

[TIL]21.06.08

by Joshua21 2021. 6. 23.

'''
#단락평가 마지막으로 단락 편가를 실시한 값으로 반환
print(True and 'python')
print('python' and True)
print('python' and False)

#0은 False로 취급 문자열은 True 취
print(False and 'python')
print(0 and 'python')

koran =92

english = 47
mathmatics = 86
science = 81

print('불합격' or korea<90 or english < 47 or nmathmatics < 50 or science < 50)



kor,eng,mat,sci = map(int, input().split())

pass = kor >= 90 and eng > 80 and mat > 85 and sci>=80
print(pass)


hello = 'hello, world!'
print(hello)

hello = "hello, world!"
print(hello)


hello = hello, world!
안녕하세요.
python입니다.

print(hello)


s = "python isn't difficult"

print(s)

s= 'he said " pythone is easy"'
print(s)



print("""python is a programming laguage that lets you work quickly""","\n and","\n integrate systems more effectively")

#리스트는 문자열 정수 실부 불등 모든 자료형을 저장할수 있으며 자료형을 섞어서 저장해도 됨

person=['davic',176]

a = [] ,b= list() 리스트를 만드는 두가지 방법

#range 연속된 숫자를 생성해줌


print(range(10))


a = list(range(10))
print(a)

#리스트 range(시작,끝,증가폭) 
a = list(range(0,10,-1))

print(a)


a = list(range(0,11))
print(a)

b = list(range(0,13,2))
print(b)

c = list(range(13,2,-2))
print(c)

d = list(range(-8,9,2))
print(d)

e = list(range(-100,101,50))
print(e)         
         


# 튜플은 리스트처럼 요소를 일렬로 저장하지만 안에 저장된 요소를 변경,추가,삭제가 불가능(읽지전용리스트)


a = (38,21,53,62,19)
print(type(a))
print(a)

person =('jameson',17,175,True)

print(person)         


#요소가 한개인 튜플 만들기

a=(38)

print(type(a))

b= (38,)
print(type(b))


a= tuple(range(10))

print(a)

b = tuple(range(5,12))

print(b)


c= tuple(range(-4,10,2))

print(c)


a = [1,2,3]

tuple(a)

print(a)

b = (4,5,6)

list(b)

print(b)



print(list('helloe'))

print(tuple('hello'))

a,b,c=[1,2,3]
print(a,b,c)


x = [1,2,3]
a,b,c=x
print(a,b,c)

y=(4,5,6)
d,e,f=y
print(d,e,f)



x = input().split()


print(type(x))

a,b = x
print(a,b)


a = list(range(5,-10,-2))

print(a)


instart = input('시작 값을 입력하세요')
inend = input('끝 값을 입력하세요')
test = input('증감폭을 입력하세요')
print(range(10,-10,int(x)))



#시퀸스 자료형 리스트 튜플 range 문자열 을seqeenunce 자료형 이라고 부름


a= [0,10,20,30,40,50,60,70,80,90]

print(100 not in a)



43 not in (38,76,43,62,19)

1 not in rnage(10)

'p' not in 'hello'


x = list(range(1,20,2))

print(12 not in x)

print(4 in x)

insert = input()


data1=['사과','배','귤','오렌지']

data2=['토마토','바나나','수박','딸기']

bend = data1 or data2

print('사과' in bend)

print(('사과' in data1) or('사과' in data2))

print([1,2,3,4]*3)

#range는 리스트 똔ㄴ 튜플로 만들어서 반복됨문자열은 *연산자를 사용하여 반복가능

#len 리스트의 요소 개수 구하기 '"는 문자열갯수로 세지않음 공백은 포함
a = [0,10,20,30,40,50,60,70,80,90]
print(len(a))

flu1=['사과','배','귤','오렌지']

flu2=['토마토','바나나','수박','딸기']

total = flu1 + flu2

print(len(total))


a = list(range(1,20,2))


print(a[2])


a = list(range(0,101,2))

print(a[-3])

#요소에 값 할당하기 
a = [38,21,53,62,19]

a[1]=11


b=(0,0,0,0,0)
b[0]=33


#
r = range(0,10,2)

r[0] = 3

hlleo = 'hello world'
hello[0]=@

a = [38,21,53,62,19]

del a[2]
print(a)

a = [0,10,20,30,40,50,60,70,80,90]
print(a[1:1])

print(a[1:2])


#a[시작:끝:증가폭]

a[:7] #인덱스 처음부터 (7-1)6번째 까지 가져옴
a[7:] #인덱스 4부터 끝까지 가져옴
a[:] # 리스트 전체를 가져옴
a[:].a[::]는 결과가 같

#  튜플 , range , 문자열에서도 시퀸스 자료형 이므로 슬라이스 사용가능
b = (0,10,20,30,40,50,60,70,80,90)

#range는 지정된 범위의 숫자를 생성하는 range 객체를 만듬

r = range(10)

print(r[4:7])

print(r[4:])

print(r[:7:2])


a = [0,10,20,30,40,50]
a[2:5] = ['a','b','c']

print(a)

'''

'First step > AI 기초반' 카테고리의 다른 글

[TIL]21.06.11  (0) 2021.06.23
[TIL]21.06.10  (0) 2021.06.23
[TIL]21.06.09  (0) 2021.06.23
[TIL]21.06.07  (0) 2021.06.23
[TIL] 21.06.15 파이썬 연습문제 while,for 반복문활용  (0) 2021.06.15