if 3 < 5 :
print ("3 < 5가 참이면 이 문장이 표시됨")
if 3 > 5 :
print ("3 > 5가 참이면 이 문장이 표시됨")
if 3 <= 5 :
print ("3 <= 5가 참이면 이 문장이 표시됨")
if 3 >= 5 :
print ("3 >= 5가 참이면 이 문장이 표시됨")
if 3 == 5 :
print ("3 == 5가 참이면 이 문장이 표시됨")
if 3 != 5 :
print ("3 != 5가 참이면 이 문장이 표시됨")
temp = 33
user_want_temp = 26
if temp <= user_want_temp :
print("에어컨을 잠시 멈춥니다.")
water_melon = 25000
if water_melon < 20000 :
print("수박을 한 통 구입합니다")
temp = 27
user_want_temp = 26
if temp <= user_want_temp :
print("에어컨을 잠시 멈춥니다.")
else :
print("에어컨을 가동합니다.")
water_melon = 19000
if water_melon < 20000 :
print("수박을 2통 구입합니다.")
else :
print("수박을 1통 구입합니다.")
water_melon = 19000
cider = 950
if water_melon < 20000 :
if cider < 1000 :
print("수박 1통과 사이다 1개를 구입합니다.")
water_melon = 19000
cider = 1000
if water_melon < 20000 :
if cider < 1000 :
print("수박 1통과 사이다 1개를 구입합니다.")
else:
print("수박은 싼 데 사이다가 비싸서 아무 것도 안 사감")
else:
print("일단 수박부터 비싸서 아무 것도 안 사감")
if water_melon < 20000 :
print("수박을 3통 구입합니다.")
else :
if water_melon < 25000 :
print("수박을 2통 구입합니다.")
else :
print("수박을 1통 구입합니다.")
if water_melon < 20000 :
print("수박을 3통 구입합니다.")
elif water_melon < 25000 :
print("수박을 2통 구입합니다.")
else :
print("수박을 1통 구입합니다.")
message = "" # 메시지
late = 20 # 지각할 거 같은 시간(분)
if late < 5 :
message = ""
elif late < 20 :
message = "미안하다"
else:
message = "오늘 자동차가 펑크날거 같아"
if message != "":
print("친구에게 다음과 같이 메시지를 보냈습니다: ", message)
a = 0
while a < 3 :
print (a)
a = a + 1
a = 0
while True :
print (a)
a = a + 1
a = 1
while a <= 99 :
print(a)
a = a + 2
data = [1, 2, 3, 4, 5]
for a in data :
print (a)
nums = [1,2,3,4,5,6,7,8,9]
for a in nums :
print (a)
food_list = ["짜장", "회", "탕수육", "트러플버섯", "치킨"]
for food in food_list :
print (food)
food_list = ["짜장", "회", "탕수육", "트러플버섯", "치킨"]
for food in food_list :
if food == "치킨" :
print (food, "찾았다!")
food_list = ["짜장", "회", "탕수육", "트러플버섯", "치킨"]
index = 0
for food in food_list :
if food == "탕수육" :
print (food, "찾았다!", index, "번째에 있었어!")
index = index + 1
food_list = ["짜장", "회", "탕수육", "트러플버섯", "치킨"]
index = 0
for food in food_list :
if food == "탕수육" :
print (food, "찾았다!", index, "번째에 있었어!")
break;
index = index + 1
food_list = ["짜장", "회", "탕수육", "트러플버섯", "치킨"]
index = 0
for food in food_list :
print(index, "번째 자료 조사 중...")
if food == "탕수육" :
print (food, "찾았다!", index, "번째에 있었어!")
index = index + 1
food_list = ["짜장", "회", "탕수육", "트러플버섯", "치킨"]
index = 0
for food in food_list :
print(index, "번째 자료 조사 중...")
if food == "탕수육" :
print (food, "찾았다!", index, "번째에 있었어!")
break;
index = index + 1
food_list = ["짜장", "회", "탕수육", "트러플버섯", "치킨"]
for food in food_list :
if food != "트러플버섯" :
continue
print (food, "사 주세요!")
for i in range(5):
print(i)
a = [i for i in range(10)]
a = [i*2 for i in range(10)]
def plus1(a) :
b = a + 1
plus1(10)
def plus1(a) :
b = a + 1
return b
c = plus1(10)
print(c)
def plus_2(a, b) :
return a + b
a = plus_2(10, 20)
print(a)
def minus_2(a, b) :
return a - b
a = minus_2(10, 20)
print(a)
def get_max(a, b):
if a < b :
return b
else :
return a
res = get_max(10, 11)
print(res)
def get_min(a, b):
if a < b :
return a
else :
return b
res = get_min(10, 11)
print(res)
a = input()
print(a)
a = input(“입력하세요:”)
print(a)
a = int( input("1~3중 입력하세요: ") )
print(a)
a = int( input("숫자를 입력하세요: ") )
b = a + 1
print("결과 :" , b)
a = int( input("숫자를 입력하세요: ") )
b = a - 1
print("결과 :" , b)
a = input("이름을 입력하세요: ")
b = a + "님 안녕하세요"
print("결과 : " , b)
# 파일 생성하고 열기
file = open("sample.txt", 'w')
# 파일에 내용 쓰기
file.write("안녕하세요")
# 파일 닫기. 파일을 열었으면 꼭 닫아야 한다
file.close()
# 파일 생성하고 열기
file = open("sample.txt", 'r')
# 파일 내용에서 맨 위 한 줄 읽어 오기
line = file.readline()
print (line)
# 파일 닫기. 파일을 열었으면 꼭 닫아야 한다
file.close()
file = open("여러줄.txt", 'w')
index = 1
while index <= 100 :
file.write(str(index))
file.write("\n")
index = index + 1
file.close()
file = open("여러줄.txt", 'r')
while True:
line = file.readline()
if not line:
break;
print (line)
file.close()
file = open("여러줄.txt", 'r')
all_line_list = file.readlines()
for line in all_line_list :
print(line)
file.close()
file = open("sample.csv", 'w')
file.write ("이름,전화번호\n")
file.write ("홍길동,02-1111-1111\n")
file.write ("박길동,02-1111-2222\n")
file.write ("최길동,03-1111-3333\n")
file.close()
저는 <b>치즈</b>를 좋아하는 <b>MIN</b>입니다.
저는 <a>치즈</a>를 좋아하는 <a>MIN</a>입니다.
저는 <a href='https://www.lx.or.kr'>치즈</a>를 좋아하는 <a>MIN</a>입니다.
저는 <a href='https://www.lx.or.kr' target='_blank'>치즈</a>를 좋아하는 <a>MIN</a>입니다.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
<ul>
<li>한식</li>
<li>
중식
<ol>
<li>짜장면</li>
<li>짬뽕</li>
</ol>
</li>
</ul>
<table>
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<table border=1>
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<table border=1>
<tr>
<td colspan=2>cell 1</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<table border=1>
<tr>
<td rowspan=2>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 4</td>
</tr>
</table>
<table border=1>
<tr>
<th>cell 1</th>
<th>cell 2</th>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<table border=1>
<tr>
<th>cell 1</th>
<th>cell 2</th>
</tr>
<tr style="background-color: yellow">
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<table border=1>
<tr>
<th>cell 1</th>
<th>cell 2</th>
</tr>
<tr>
<td style="background-color: red">cell 3</td>
<td>cell 4</td>
</tr>
</table>
<table border=1>
<tr style="background-color: #FF0000">
<th>cell 1</th>
<th>cell 2</th>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
import requests
requests.get('https://www.lx.or.kr')
import requests
requests.get('https://www.lx.or.kr/aaaaa.hwp')
import requests
response = requests.get('https://lxeduweb.web.app')
response
import requests
response = requests.get('https://lxeduweb.web.app/1.html')
import requests
response = requests.get('https://lxeduweb.web.app/1.html')
A = response.text.find('A전자')
start = response.text.find('<td>', A + 3)
end = response.text.find('</td>', start + 1)
price = response.text[start+4 : end]
price
import requests
response = requests.get('https://lxeduweb.web.app/1.html')
A = response.text.find('A전자')
start = response.text.find('<td>', A + 3)
end = response.text.find('</td>', start + 1)
price = response.text[start+4 : end]
print("A전자 현재가:", price)
import json
data = '{"name": "홍길동", "year": 1999, "phone": "010-1111-1111"}'
value = json.loads(data)
print(value["phone"])
import schedule
import time
# 실행할 함수 정의
def task():
print("task 실행")
#1초에 한 번씩 실행
schedule.every(1).seconds.do(task)
while True:
schedule.run_pending()
time.sleep(1)
import schedule
import time
# 실행할 함수 정의
def task():
print("task 실행")
#1분에 한 번씩 실행
schedule.every(1).minutes.do(task)
while True:
schedule.run_pending()
time.sleep(1)
import schedule
import time
# 실행할 함수 정의
def task():
print("task 실행")
# 1시간에 한 번씩 실행
schedule.every(1).hour.do(task)
while True:
schedule.run_pending()
time.sleep(1)
import schedule
import time
# 실행할 함수 정의
def task():
print("task 실행")
# 매일 00:00에 실행
schedule.every().day.at("00:00").do(task)
while True:
schedule.run_pending()
time.sleep(1)
from openpyxl import Workbook
wb = Workbook()
# 워크북(엑셀)에서 활성화된 sheet을 ws라 부름.
ws = wb.active
# A1 셀에 자료 할당
ws['A1'] = '공개값'
ws['B2'] = 42
# 파일 저장
wb.save("sample.xlsx")
from openpyxl import Workbook
wb = Workbook()
# 워크북(엑셀)에서 활성화된 sheet을 ws라 부름.
ws = wb.active
# A1 셀에 자료 할당
ws['A1'] = '공개값'
ws['B2'] = 42
c = ws['B2'].value
ws['C3'] = c + 1
# 파일 저장
wb.save("sample2.xlsx")
from openpyxl import load_workbook
wb = load_workbook(filename = 'sample2.xlsx)
# 워크북(엑셀)에서 활성화된 sheet을 ws라 부름.
ws = wb['Sheet']
v = ws['C3'].value
print("v:", v)
from pptx import Presentation
prs = Presentation() # 파워포인트형으로 객체 생성
slide_layout = prs.slide_layouts[1] # 레이아웃 설정
slide = prs.slides.add_slide(slide_layout) # 슬라이드 하나 추가
slide.shapes.title.text = "제목"
slide.shapes.placeholders[1].text_frame.text = '내용1'
slide.shapes.placeholders[1].text_frame.add_paragraph().text = '내용2'
prs.save('sample.pptx') # 파일 저장