<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>joy_all.log</title>
        <link>https://velog.io/</link>
        <description>beginner</description>
        <lastBuildDate>Wed, 31 Mar 2021 07:57:43 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>joy_all.log</title>
            <url>https://images.velog.io/images/joy_all/profile/6c620458-caa7-4452-89b6-11660741c47a/KakaoTalk_20210121_205617984.jpg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. joy_all.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/joy_all" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[Python 13]]></title>
            <link>https://velog.io/@joy_all/Python-13</link>
            <guid>https://velog.io/@joy_all/Python-13</guid>
            <pubDate>Wed, 31 Mar 2021 07:57:43 GMT</pubDate>
            <description><![CDATA[<h2 id="📒-파일입출력">📒 파일입출력</h2>
<h4 id="open파일명모드-내장함수">open(&quot;파일명&quot;,&quot;모드&quot;) 내장함수</h4>
<h4 id="w-파일쓰기-r-파일읽기-a-파일에-추가">w-파일쓰기, r-파일읽기, a-파일에 추가</h4>
<pre><code class="language-python">test.txt -&gt; testFile
test1234</code></pre>
<h3 id="📍-파일읽기">📍 파일읽기</h3>
<pre><code class="language-python">f = open(&quot;test.txt&quot;,&quot;r&quot;)
print(f)</code></pre>
<blockquote>
<p>&lt;_io.TextIOWrapper name=&#39;test.txt&#39; mode=&#39;r&#39; encoding=&#39;cp949&#39;&gt;</p>
</blockquote>
<h3 id="📍-해당파일의-내용-첫줄만-읽어오기">📍 해당파일의 내용 첫줄만 읽어오기</h3>
<pre><code class="language-python">f = open(&quot;test.txt&quot;,&quot;r&quot;)
print( f.readline() )</code></pre>
<blockquote>
<p>test.txt -&gt; testFile</p>
</blockquote>
<h3 id="📍-파일-불러오기-다쓴후-파일-자원해제-해야함">📍 파일 불러오기 (다쓴후 파일 자원해제 해야함)</h3>
<pre><code class="language-python">while True:
    line = f.readline()

    if not line:
        break

    print(line)

f.close()   # 자원해제</code></pre>
<blockquote>
<p>test.txt -&gt; testFile
test1234</p>
</blockquote>
<h3 id="📍-파일의-내용을-리스트로-읽어오기">📍 파일의 내용을 리스트로 읽어오기</h3>
<pre><code class="language-python">f2 = open(&quot;test.txt&quot;,&quot;r&quot;)
print(f2.readlines())</code></pre>
<blockquote>
<p>test1234
[&#39;test.txt -&gt; testFile\n&#39;, &#39;test1234&#39;]</p>
</blockquote>
<pre><code class="language-python">f2 = open(&quot;test.txt&quot;,&quot;r&quot;)
for i in f2.readlines():
    print(i)
f2.close()</code></pre>
<blockquote>
<p>test.txt -&gt; testFile
test1234</p>
</blockquote>
<h3 id="📍-csv-파일-읽어오기">📍 .csv 파일 읽어오기</h3>
<pre><code class="language-python">f3 = open(&quot;birth.csv&quot;,&quot;r&quot;)
for a in f3.readlines():
    print(a)

f3.close()</code></pre>
<blockquote>
<p>&quot;시점&quot;,전국,서울특별시,부산광역시,대구광역시,인천광역시,광주광역시,대전광역시,울산광역시,세종특별자치시,경기도,강원도,충청북도,충청남도,전라북도,전라남도,경상북도,경상남도,제주특별자치도
&quot;2015&quot;,438420,83005,26645,19438,25491,12441,13774,11732,2708,113495,10929,13563,18604,14087,15061,22310,29537,5600
&quot;2016&quot;,406243,75536,24906,18298,23609,11580,12436,10910,3297,105643,10058,12742,17302,12698,13980,20616,27138,5494
&quot;2017&quot;,357771,65389,21480,15946,20445,10120,10851,9381,3504,94088,8958,11394,15670,11348,12354,17957,23849,5037</p>
</blockquote>
<h3 id="📍-이미지-파일은-안됨">📍 이미지 파일은 안됨.</h3>
<pre><code class="language-python">f4 = open(&quot;2.jpg&quot;,&quot;r&quot;)
for a in f4.readlines():
    print(a)

f4.close()</code></pre>
<blockquote>
<p>FileNotFoundError: [Errno 2] No such file or directory: &#39;2.jpg&#39;</p>
</blockquote>
<h2 id="📒-파일-쓰기">📒 파일 쓰기</h2>
<h3 id="기본적으로-덮어쓰기-주의">기본적으로 덮어쓰기 (주의)</h3>
<h3 id="📍-파이참에-파일-생성">📍 파이참에 파일 생성</h3>
<pre><code class="language-python">f5 = open(&quot;fileTest.txt&quot;,&quot;w&quot;)

data = &quot;itwill busan&quot;

for i in range(0,len(data)):
    # print(data[i])
    f5.write(data[i])
f5.close()</code></pre>
<blockquote>
<p>fileTest.txt
-&gt; itwill busan</p>
</blockquote>
<h3 id="📍-특정위치에-파일-생성">📍 특정위치에 파일 생성</h3>
<pre><code class="language-python">f6 = open(&quot;D:/JSP/fileTest1.txt&quot;,&quot;w&quot;)
for i in range(1,6):
    f6.write(&quot; %d 입력 \n&quot; %i)</code></pre>
<blockquote>
<p>D:\JSP\fileTest1.txt 내 컴퓨터에 파일 생성
 1 입력 
 2 입력 
 3 입력 
 4 입력 
 5 입력 </p>
</blockquote>
<h3 id="📍-파일에-내용추가">📍 파일에 내용추가</h3>
<pre><code class="language-python">f7 = open(&quot;test.txt&quot;,&quot;a&quot;)

f7.write(&quot;hello append~!!&quot;)
f7.close()</code></pre>
<blockquote>
<p>test.txt -&gt; 6hello append~!! 추가됨</p>
</blockquote>
<h3 id="📍-파일-내용-뒤집기">📍 파일 내용 뒤집기!</h3>
<p><img src="https://images.velog.io/images/joy_all/post/490b9180-505b-458e-8a5a-d43cccbc8294/image.png" alt=""></p>
<ul>
<li>파일을 리스트로 읽을 수 있음.</li>
<li>fileTest.txt 파일의 내용을 역순으로 뒤집어서 사용<pre><code class="language-python">fo = open(&quot;fileTest.txt&quot;,&quot;r&quot;)
</code></pre>
</li>
</ul>
<p>lists = fo.readlines()</p>
<p>fo.close()</p>
<p>print(lists)
lists.reverse()
print(lists)</p>
<p>fo2 = open(&quot;fileTest.txt&quot;,&quot;w&quot;)</p>
<p>for i in lists:
    fo2.write(i)</p>
<p>fo2.close()</p>
<pre><code>&gt;![](https://images.velog.io/images/joy_all/post/9dd4242d-3ad4-4c49-84ca-86f0638ae62e/image.png)</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[Python 12]]></title>
            <link>https://velog.io/@joy_all/Python-12</link>
            <guid>https://velog.io/@joy_all/Python-12</guid>
            <pubDate>Wed, 31 Mar 2021 06:57:25 GMT</pubDate>
            <description><![CDATA[<h1 id="📒-예외처리">📒 예외처리</h1>
<pre><code class="language-python">try:
    예외가 발생할 수도 있는 코드
except 예외:
    예외 처리</code></pre>
<h4 id="프로그램이-비정상적인-종료를-하지않도록-함">프로그램이 비정상적인 종료를 하지않도록 함</h4>
<h3 id="📍-에러메세지">📍 에러메세지</h3>
<pre><code class="language-python">print(4/0)</code></pre>
<blockquote>
<p>ZeroDivisionError: division by zero</p>
</blockquote>
<h3 id="📍-except-메세지-출력">📍 except 메세지 출력</h3>
<pre><code class="language-python">print(&quot; 시작 &quot;)

try:
    print( 4 / 0 )
except:
    print(&quot;예외처리! 예외발생!!!&quot;)

print(&quot; 끝 &quot;)</code></pre>
<blockquote>
<p>시작 
예외처리! 예외발생!!!
 끝 </p>
</blockquote>
<h3 id="📍-indexerror-안맞으면-에러발생">📍 IndexError 안맞으면 에러발생</h3>
<pre><code class="language-python">print(&quot; 시작 &quot;)

try:
    print( 4 / 0 )
except IndexError:
    print(&quot;예외처리! 예외발생!!!&quot;)

print(&quot; 끝 &quot;)</code></pre>
<blockquote>
<p>시작<br>ZeroDivisionError: division by zero</p>
</blockquote>
<h3 id="📍-두개-가능">📍 두개 가능</h3>
<pre><code class="language-python">print(&quot; 시작 &quot;)

try:
    print( 4 / 0 )
except IndexError:
    print(&quot;예외처리! 예외발생!!!&quot;)
except ZeroDivisionError:
    print(&quot; 0으로 나누기 예외!!! &quot;)

print(&quot; 끝 &quot;)</code></pre>
<blockquote>
<p>시작 
 0으로 나누기 예외!!! 
 끝 </p>
</blockquote>
<h3 id="📍-e-로-에러-알려주기">📍 e 로 에러 알려주기</h3>
<pre><code class="language-python">print(&quot; 시작 &quot;)

try:
    print( 4 / 0 )
except IndexError:
    print(&quot;예외처리! 예외발생!!!&quot;)
except ZeroDivisionError as e:
    print(&quot; 0으로 나누기 예외!!! &quot;,e)

print(&quot; 끝 &quot;)</code></pre>
<blockquote>
<p>시작 
 0으로 나누기 예외!!!  division by zero
 끝 </p>
</blockquote>
<pre><code class="language-python">print(&quot; 시작 ----&quot;)

try:
    print( 4 / 0 )

except (ZeroDivisionError,IndexError) as e:
    # raise FileNotFoundError  에러를 강제로 발생
    # pass  에러(예외)발생시 아무런 동작없이 처리
    print(&quot; 0으로 나누기 예외!!! &quot;,e)

print(&quot; 끝 ---- &quot;)</code></pre>
<blockquote>
<p>시작 ----
 0으로 나누기 예외!!!  division by zero
 끝 ----</p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[Python 11]]></title>
            <link>https://velog.io/@joy_all/Python-11</link>
            <guid>https://velog.io/@joy_all/Python-11</guid>
            <pubDate>Wed, 31 Mar 2021 06:31:41 GMT</pubDate>
            <description><![CDATA[<h1 id="📒-모듈">📒 모듈</h1>
<ul>
<li>모듈 : 변수, 함수, 클래스를 모아놓은 파일</li>
<li>=&gt; 다른 파이썬 파일에서 실행할 수 있게 만들어진 파이썬 파일
<img src="https://images.velog.io/images/joy_all/post/0c81c546-32d9-419b-92ae-36dd284408e1/%EC%BA%A1%EC%B2%98x.PNG" alt=""></li>
</ul>
<h2 id="📍-mod1py-모듈을-가져와서-사용해보기">📍 mod1.py 모듈을 가져와서 사용해보기</h2>
<h3 id="📍-import-모듈명----해당-모듈-전체를-추가">📍 import 모듈명  -&gt; 해당 모듈 전체를 추가</h3>
<pre><code class="language-python"># mod1.py

# 덧셈 연산 모듈
def add(a,b):
    return a+b</code></pre>
<pre><code class="language-python">import mod1
print(&quot;모듈 실행결과 : &quot;,mod1.add(100,200))</code></pre>
<blockquote>
<p>모듈 실행결과 : 300</p>
</blockquote>
<pre><code class="language-python">from mod1 import add
print(&quot;모듈 실행결과&quot;,add(200,300))</code></pre>
<blockquote>
<p>모듈 실행결과 500</p>
</blockquote>
<h3 id="📍-from-모듈명-import-모듈함수----해당-모듈의-특정-함수만-추가">📍 from 모듈명 import 모듈함수  -&gt; 해당 모듈의 특정 함수만 추가</h3>
<pre><code class="language-python"># mod1.py

# 사칙 연산 모듈

def add(a,b):
    return a+b

def sub(a,b):
    return a-b

def mul(a,b):
    return a*b

def div(a,b):
    return a/b</code></pre>
<pre><code class="language-python">import mod1
print(&quot;모듈 실행결과 : &quot;,mod1.add(100,200))
print(&quot;모듈 실행결과 : &quot;,mod1.mul(300,400))</code></pre>
<blockquote>
<p>모듈 실행결과 : 300
모듈 실행결과 : 120000</p>
</blockquote>
<ul>
<li>from mod1 import add</li>
<li>from mod1 import add,mul</li>
</ul>
<pre><code class="language-python">from mod1 import *

print(&quot;모듈 실행결과&quot;,add(200,300))
# print(&quot;모듈 실행결과&quot;,mul(200,300)) 해당 모듈의 함수를 추가없이 사용X
print(&quot;모듈 실행결과&quot;,mul(200,300))</code></pre>
<blockquote>
<p>모듈 실행결과 500
모듈 실행결과 60000</p>
</blockquote>
<h3 id="📍-name--파이썬-내부에서-사용하는-변수">📍 <strong><strong>name</strong></strong> : 파이썬 내부에서 사용하는 변수</h3>
<ul>
<li><p>해당 파일을 실행시 <strong><strong>main</strong></strong>값 저장</p>
</li>
<li><p>다른 파이썬파일(모듈)에서 실행 추가한 모듈의 이름이 저장</p>
</li>
<li><p>모듈(해당파일에서는) <strong><strong>name</strong></strong> 값 : <strong><strong>main</strong></strong></p>
</li>
<li><p>모듈을 추가 파일  <strong><strong>name</strong></strong> 값 : <strong><strong>main</strong></strong> (X)</p>
<pre><code class="language-python">if __name__ == &quot;__main__&quot;:
  print(&quot;모듈 실행!&quot;)
  print(add(10,20))
  print(div(10,30))</code></pre>
</li>
</ul>
<h3 id="📍import-mod2">📍import mod2</h3>
<pre><code class="language-python"># mod2.py
# 모듈 (변수, 클래스)

PI = 3.141592

def add(a,b):
    return a+b

class Math:
    def solv(self,r):
        return PI * (r ** 2) # 파이 곱하기 r제곱</code></pre>
<pre><code class="language-python">import mod2

print(&quot;변수 값 출력 : &quot;, mod2.PI)
print(&quot;함수 호출 : &quot;,mod2.add(100,200))</code></pre>
<blockquote>
<p>변수 값 출력 :  3.141592
함수 호출 :  300</p>
</blockquote>
<h3 id="📍모듈안에-있는-객체를-생성후-사용">📍모듈안에 있는 객체를 생성후 사용</h3>
<pre><code class="language-python">myMath = mod2.Math()
print(myMath.solv(5))</code></pre>
<blockquote>
<p>78.5398</p>
</blockquote>
<h2 id="📒-패키지">📒 패키지</h2>
<h4 id="연산자를-사용해서-파이썬-모듈을-관리하는-묶음">(.)연산자를 사용해서 파이썬 모듈을 관리하는 묶음</h4>
<h4 id="비슷한-기능들끼리-묶어서-사용">비슷한 기능들끼리 묶어서 사용</h4>
<h3 id="📍-패키지모듈">📍 패키지.모듈</h3>
<pre><code class="language-python"># info.py
# 모듈

def sayHello():
    print(&quot;안녕하세요~!&quot;)</code></pre>
<pre><code class="language-python">import itwill.info

itwill.info.sayHello()

from itwill.info import sayHello

sayHello()</code></pre>
<blockquote>
<p>안녕하세요<del>!
안녕하세요</del>!</p>
</blockquote>
<h3 id="📍-as-로-이름-줄이기">📍 as 로 이름 줄이기</h3>
<pre><code class="language-python"># TeamProject.py
def project():
    print(&quot;팀프로젝트 진행중!&quot;)</code></pre>
<pre><code class="language-python">import itwill.class5.TeamProject
itwill.class5.TeamProject.project()
# --------------------------------------------------
from itwill.class5.TeamProject import project
project()


import itwill.class5.TeamProject as tp
itwill.class5.TeamProject.project()
tp.project()
# --------------------------------------------------
from itwill.class5.TeamProject import project as pj
project()
pj()</code></pre>
<blockquote>
<p>팀프로젝트 진행중!
팀프로젝트 진행중!
팀프로젝트 진행중!
팀프로젝트 진행중!
팀프로젝트 진행중!
팀프로젝트 진행중!</p>
</blockquote>
<h2 id="📒-내장함수--기본-패키지에-있는-모듈">📒 내장함수 : 기본 패키지에 있는 모듈</h2>
<h2 id="📒-외장함수--외부-패키지에-있는-모듈">📒 외장함수 : 외부 패키지에 있는 모듈</h2>
<h3 id="📍-랜덤--랜덤값-불러오기">📍 랜덤 / 랜덤값 불러오기</h3>
<pre><code class="language-python">import random as r

print(r.random())
print(r.randint(1,10))</code></pre>
<blockquote>
</blockquote>
<p>0.30714512297228247
6</p>
<h3 id="📍-달력-2021-불러오기">📍 달력 2021 불러오기</h3>
<pre><code class="language-python">import calendar as cal
print(cal.calendar(2021))</code></pre>
<blockquote>
<p><img src="https://images.velog.io/images/joy_all/post/ec902f79-98dc-4b54-8455-59172c886596/%EC%BA%A1%EC%B2%98.PNG" alt=""></p>
</blockquote>
<h3 id="📍-웹-브라우저">📍 웹 브라우저</h3>
<pre><code class="language-python">import webbrowser as web
web.open(&quot;http://www.naver.com&quot;)</code></pre>
<blockquote>
<p>네이버 오픈</p>
</blockquote>
<pre><code class="language-python"># itwill/class1/hello.py

def hello():
    print(&quot;class1_hello!&quot;)</code></pre>
<pre><code class="language-python"># itwill/class1/hello 모듈 실행
import itwill.class1.hello as h
h.hello()</code></pre>
<blockquote>
<p>class1_hello!</p>
</blockquote>
<h3 id="📍-패키지-생성시-자동으로-initpy-파일이-생성됨">📍 패키지 생성시 자동으로 <strong>init</strong>.py 파일이 생성됨</h3>
<h4 id="--initpy--해당-디렉토리가-패키지의-일부다-라는-의미로-사용">-&gt; <strong><strong>init</strong></strong>.py : 해당 디렉토리가 패키지의 일부다 라는 의미로 사용</h4>
<h4 id="33버전-이전의-경우-해당-파일이-없을-경우-에러-발생">3.3버전 이전의 경우 해당 파일이 없을 경우 에러 발생</h4>
]]></description>
        </item>
        <item>
            <title><![CDATA[Python 6]]></title>
            <link>https://velog.io/@joy_all/Python-6</link>
            <guid>https://velog.io/@joy_all/Python-6</guid>
            <pubDate>Wed, 24 Mar 2021 06:03:49 GMT</pubDate>
            <description><![CDATA[<h2 id="📒-데이터-표현">📒 데이터 표현</h2>
<h4 id="import-추가라이브러리-as-이름">import 추가라이브러리 as 이름</h4>
<h4 id="💚-pandas--데이터분석많은-데이터-처리csv파일-리드">💚 pandas : 데이터분석(많은 데이터 처리),csv파일 리드</h4>
<h4 id="💚-matplotlibpyplot--시각화">💚 matplotlib.pyplot : 시각화</h4>
<pre><code class="language-python">import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_csv(&#39;franchise.csv&#39;)
# print(df)
plt.rcParams[&#39;font.family&#39;]=&quot;Malgun Gothic&quot;
plt.rcParams[&#39;axes.unicode_minus&#39;]=False

ind = np.arange(len(df))

plt.plot(df[&#39;chicken&#39;],&quot;r:.&quot;,label=&quot;치킨&quot;)
plt.plot(df[&#39;coffee&#39;],&quot;b:.&quot;,label=&quot;커피&quot;)
plt.xticks(ind,df[&#39;year&#39;])
plt.legend()
plt.show()</code></pre>
<blockquote>
</blockquote>
<p><img src="https://images.velog.io/images/joy_all/post/98be0927-3b35-4d73-9293-9ec45b08f1b7/9990.PNG" alt="">
<img src="https://images.velog.io/images/joy_all/post/5021b11b-4215-4686-8a7a-7d8512db7e09/999.PNG" alt=""></p>
<pre><code class="language-python">import pandas as ps
import matplotlib.pyplot as plt

df = ps.read_csv(&#39;move_P.csv&#39;,encoding=&#39;euc-kr&#39;)
# print(df)

ind = range(len(df))
# print(ind)

plt.plot(ind, df[&#39;서울특별시&#39;],&#39;b-&#39;,label=&quot;seoul&quot;)
plt.plot(ind, df[&#39;부산광역시&#39;],&#39;g--&#39;,label=&quot;busan&quot;)
plt.plot(ind, df[&#39;세종특별자치시&#39;],&#39;r-.&#39;,label=&quot;sejong&quot;)
plt.plot(ind, df[&#39;제주특별자치도&#39;],&#39;y:&#39;,label=&quot;jeju&quot;)

plt.xticks(ind, df[&#39;시점&#39;])
plt.ylabel(&quot;number&quot;)
plt.xlabel(&quot;city&quot;)


plt.legend()

plt.show()</code></pre>
<blockquote>
</blockquote>
<p><img src="https://images.velog.io/images/joy_all/post/08c26cfe-a3da-42bd-8bf2-db6faab796c3/4.PNG" alt=""></p>
<pre><code class="language-python">import pandas as ps
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams[&#39;font.family&#39;]=&quot;Malgun Gothic&quot;
plt.rcParams[&#39;axes.unicode_minus&#39;]=False

df = ps.read_csv(&#39;population.csv&#39;)

# print(df)

w = 0.4
idx = np.arange(len(df))


plt.bar(idx-w/2, df[&#39;men&#39;] ,width=w,color=&#39;b&#39;,label=&quot;남성&quot;)
plt.bar(idx+w/2, df[&#39;women&#39;] ,width=w,color=&#39;r&#39;,label=&quot;여성&quot;)

plt.xticks(idx,df[&#39;local&#39;])
plt.title(&quot; 도시별 인구수 &quot;)

plt.legend()

plt.show()</code></pre>
<blockquote>
</blockquote>
<p><img src="https://images.velog.io/images/joy_all/post/0966e0d3-9cef-4fd2-aa17-5c38396a94bb/2.PNG" alt=""></p>
<pre><code class="language-python">import pandas as ps
import numpy as np
import matplotlib.pyplot as plt


plt.rcParams[&#39;font.family&#39;]=&quot;Malgun Gothic&quot;
plt.rcParams[&#39;axes.unicode_minus&#39;]=False

df =ps.read_csv(&#39;birth.csv&#39;,encoding=&#39;euc-kr&#39;)

w = 0.3
idx = np.arange(len(df))
# print(idx)

plt.bar(idx-w,df[&#39;서울특별시&#39;],width=w ,label=&quot;서울&quot;)
plt.bar(idx,df[&#39;부산광역시&#39;],width=w,label=&quot;부산&quot;)
plt.bar(idx+w,df[&#39;제주특별자치도&#39;],width=w,label=&quot;제주&quot;)

plt.xticks(idx,df[&#39;시점&#39;])
plt.ylabel(&quot; 인구수 &quot;)
plt.legend()

plt.show()</code></pre>
<blockquote>
</blockquote>
<p><img src="https://images.velog.io/images/joy_all/post/94d54579-a153-4831-8749-dbd518c33694/3.PNG" alt=""></p>
<pre><code class="language-python"># test10.py
#  산점도

import pandas as ps
import matplotlib.pyplot as plt

df = ps.read_csv(&#39;online.csv&#39;,encoding=&#39;euc-kr&#39;)

idx = range(len(df))

plt.figure( figsize=(8,6) )

plt.scatter(df[&#39;시점&#39;],df[&#39;컴퓨터 및 주변기기&#39;],label=&quot;com&quot;)
plt.scatter(df[&#39;시점&#39;],df[&#39;신 발&#39;])
plt.scatter(df[&#39;시점&#39;],df[&#39;가 방&#39;])
plt.scatter(df[&#39;시점&#39;],df[&#39;패션용품 및 악세사리&#39;])
plt.scatter(df[&#39;시점&#39;],df[&#39;가 구&#39;])
plt.scatter(df[&#39;시점&#39;],df[&#39;애완용품&#39;])
plt.scatter(df[&#39;시점&#39;],df[&#39;기 타&#39;])

plt.xlabel(&quot;year&quot;)
plt.ylabel(&quot;money&quot;)

plt.legend()

plt.show()
</code></pre>
<blockquote>
</blockquote>
<p><img src="https://images.velog.io/images/joy_all/post/44c96bce-55e9-48b0-836f-e89781874976/6.PNG" alt=""></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Python 5]]></title>
            <link>https://velog.io/@joy_all/Python-5</link>
            <guid>https://velog.io/@joy_all/Python-5</guid>
            <pubDate>Tue, 23 Mar 2021 03:05:33 GMT</pubDate>
            <description><![CDATA[<h2 id="📒-함수">📒 함수</h2>
<h4 id="여러가지-실행문을-한번에-실행">여러가지 실행문을 한번에 실행</h4>
<pre><code class="language-python">def 함수명(매개변수):
    실행문1
    실행문2
    pass</code></pre>
<h3 id="📍-숫자-2개를-전달받아서-사칙연산의-결과를-모두-출력하는-함수-------">📍 숫자 2개를 전달받아서 사칙연산의 결과를 모두 출력하는 함수 ( + - * / )</h3>
<pre><code class="language-python">def sum2(a,b):
    print(&quot;+ : &quot;,a+b)
    print(&quot;- : &quot;,a-b)
    print(&quot;* : &quot;,a*b)
    print(&quot;/ : &quot;,a/b)

# 함수명 사용 호출
sum2(10,20)</code></pre>
<blockquote>
</blockquote>
<p>+:  30
-:  -10
*:  200
/:  0.5</p>
<h3 id="📍-절대값을-계산하는-함수-myabs-전달인자-1개">📍 절대값을 계산하는 함수 myABS, 전달인자 1개</h3>
<h4 id="양수---양수-음수---양수-결과-리턴">양수 -&gt; 양수, 음수 -&gt; 양수 결과 리턴</h4>
<pre><code class="language-python">def myABS(num):
    if num&lt;0:
        num=-num

    return num

print(&quot;절대값 &quot;,myABS(1000))
print(&quot;절대값 &quot;,myABS(-1000))

# 리턴값없는 리턴문 =&gt; 함수의 종료
def test():
    return</code></pre>
<blockquote>
</blockquote>
<p>절대값  1000
절대값  1000</p>
<h3 id="📍-리스트-값-체크-함수---listck">📍 리스트 값 체크 함수 - listck()</h3>
<ul>
<li>리스트 하나를 전달받아서, 리스트 안에 100숫자 확인</li>
<li>숫자 있음! 숫자 없음! 출력<pre><code class="language-python">list3 = [1,2,3,4,5,200,30,400]
</code></pre>
</li>
</ul>
<p>def listck(v):
    print(&quot;전달값 &quot;,v)
    check=&quot;없음&quot;
    for i in v:
        if i == 100:
            check=&quot;있음&quot;
            break
        else:
            check=&quot;없음&quot;</p>
<pre><code>print(&quot;숫자&quot;+check)</code></pre><p>def listck2(v):</p>
<pre><code>if 100 in v:
    print(&quot;숫자 있음&quot;)
else:
    print(&quot;숫자 없음&quot;)</code></pre><pre><code>&gt;
전달값  [1, 2, 3, 4, 5, 200, 30, 400]
숫자없음
숫자 없음

```python
# def 함수명(*매개변수):
#     실행문

def test(*v):
    print(v)

test(1)
test(1,2)
test(1,2,3,3,5,1,2,4,5)</code></pre><blockquote>
</blockquote>
<p>(1,)
(1, 2)
(1, 2, 3, 3, 5, 1, 2, 4, 5)</p>
<h3 id="📍-함수의-매개변수의-값을-초기화">📍 함수의 매개변수의 값을 초기화</h3>
<ul>
<li><strong>초기화 코드는 마지막에만 사용 (컴파일에러 발생)</strong><pre><code class="language-python">def test2(name,age,tel=&quot;010-1234-7894&quot;):
  print(&quot;name&quot;,name)
  print(&quot;age&quot;,age)
  print(&quot;tel&quot;,tel)
</code></pre>
</li>
</ul>
<p>test2(&quot;홍길동&quot;,20)
test2(&quot;홍길동&quot;,20,&quot;010-1212-1212&quot;)</p>
<pre><code>&gt;
name 홍길동
age 20
tel 010-1234-7894
name 홍길동
age 20
tel 010-1212-1212

### 📍
```python
클래스 선언
class 클래스명:
    변수1
    변수2

    함수1()
    함수2()

# 클래스 생성 -&gt; 객체 생성 (생성자 호출)</code></pre><pre><code class="language-python">class Itwill:
    clasroom = 5
    def study(self):
        print(&quot;자습&quot;)

# 객체 생성
will = Itwill()
will.study()
print(will.clasroom)</code></pre>
<blockquote>
</blockquote>
<p>자습
5</p>
<h3 id="📍-계산기-객체를-사용해서-사칙연산-처리">📍 계산기 객체를 사용해서 사칙연산 처리</h3>
<pre><code class="language-python">class MyCalc:
    def mySum(self,a,b):
        print(&quot; + :&quot;,a+b)
    def mySub(self,a,b):
        print(&quot; - :&quot;,a-b)
    def myMul(self,a,b):
        print(&quot; * :&quot;,a*b)
    def myDiv(self,a,b):
        print(&quot; / :&quot;,a/b)

c = MyCalc()
c.mySub(100,200)
print(c)</code></pre>
<blockquote>
</blockquote>
<p> -:-100
&lt;<strong><strong>main</strong></strong>.MyCalc object at 0x00000270BB258760&gt;</p>
<pre><code class="language-python">생성자 : 객체 생성시 변수를 초기화
self : 객체 자신의 정보를 가지고있는 레퍼런스(this)
class 클래스명:
    def __init__(self):
        pass
    def __init__(self,name,age):
        self.name =name
        pass</code></pre>
<h3 id="📍-객체를-생성시-본인의-이름전화번호-초기화가능한-객체-생성">📍 객체를 생성시 본인의 이름,전화번호 초기화가능한 객체 생성</h3>
<ul>
<li><p>ItwillStudent 클래스 사용</p>
<pre><code class="language-python">class ItwillStudent:
 name=&quot;&quot;
 tel=&quot;&quot;

 # 생성자
 def __init__(self):
     self.name=&quot;기본학생&quot;
     self.tel=&quot;010-xxxx-xxxx&quot;
 def __init__(self,name,tel):
     self.name=name
     self.tel = tel

 def showMyInfo(self):
     print(&quot;이름 : &quot;+str(self.name)+&quot; 전화번호 : &quot;+self.tel)

</code></pre>
</li>
</ul>
<p>kim = ItwillStudent(&quot;홍길동&quot;,&quot;010-1111-2223&quot;)
kim.showMyInfo()</p>
<pre><code>&gt;
이름 : 홍길동 전화번호 : 010-1111-2223

## 📒 상속
#### class 클래스명(상속할 클래스명):
#### class 클래스명(상속할 클래스명1, 상속할 클래스명2): 다중상속가능
- 메서드 오버라이딩도 가능
```python
class Parent:
    def pprn(self):
        print(&quot;부모-pprn()&quot;)
class Child(Parent):
    def cprn(self):
        print(&quot;부모-cprn()&quot;)
    def pprn(self):
        print(&quot;부모-pprn()&quot;) #오버라이딩

p = Parent()
p.pprn()
# p.cprn() : x

c = Child()
c.cprn()
c.pprn() #상속했기 때문에 부모의 기능/속성을 사용가능</code></pre><blockquote>
</blockquote>
<p>부모-pprn()
부모-cprn()
부모-pprn()</p>
<pre><code class="language-python">class Parent:
    name=&quot;홍길동&quot;   # 클래스변수 (인스턴스 변수)
    def pprn(self):
        print(&quot;부모-pprn()&quot;)

class Child(Parent):
    def cprn(self):
        print(&quot;자식-cprn()&quot;)

    def pprn(self):
        super().pprn()  # super() 부모객체의 생성자 호출
        print(&quot;자식-pprn()&quot;)</code></pre>
<blockquote>
</blockquote>
<p>부모-pprn()
자식-cprn()
부모-pprn()
자식-pprn()</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Python 4]]></title>
            <link>https://velog.io/@joy_all/Python-4-jzgx10oq</link>
            <guid>https://velog.io/@joy_all/Python-4-jzgx10oq</guid>
            <pubDate>Tue, 23 Mar 2021 01:49:58 GMT</pubDate>
            <description><![CDATA[<h2 id="📒-반복문">📒 반복문</h2>
<pre><code class="language-python"> 초기식
 while 조건문:
    실행문
    증감식</code></pre>
<h3 id="📍-110-까지-while-사용-출력">📍 1~10 까지 while 사용 출력</h3>
<pre><code class="language-python">i = 1
while i&lt;=10:
    # print(i)
    # print(i,end=&quot;\n&quot;)
    print(i,end=&quot; &quot;)
    i+=1</code></pre>
<blockquote>
</blockquote>
<p>1 2 3 4 5 6 7 8 9 10</p>
<h3 id="📍-1100-까지-합-출력">📍 1~100 까지 합 출력</h3>
<pre><code class="language-python">total_sum = 0
i = 1
while i&lt;=100:
    total_sum += i
    i+=1
print(&quot;총합 : &quot;,total_sum)</code></pre>
<blockquote>
</blockquote>
<p>총합 :  5050</p>
<h2 id="📒-무한루프">📒 무한루프</h2>
<pre><code class="language-python">while True:
     Print(&quot;반복문 실행&quot;)
</code></pre>
<p>보조제어문 :  break문, continue문</p>
<h2 id="📒-for문">📒 for문</h2>
<pre><code class="language-python">for 변수 in 리스트(튜플,문자열):
     실행문
     실행문
</code></pre>
<pre><code class="language-python">list1 = [1,2,3,4,5,6]
list2 = (1,2,3,4,5,6)
list3 = &quot;123456&quot;
for data in list1:
    print(&quot;data : &quot;, data)
</code></pre>
<blockquote>
</blockquote>
<p>data :  1
data :  2
data :  3
data :  4
data :  5
data :  6     //list 1,2,3 다 같은 결과</p>
<pre><code class="language-python">data1 = [(1,2),(3,4),(5,6)]
data2 = {(1,2),(3,4),(5,6)}
print(type(data1))
print(type(data2))
</code></pre>
<blockquote>
</blockquote>
<p>&lt;class &#39;list&#39;&gt;
&lt;class &#39;set&#39;&gt;</p>
<pre><code class="language-python">for d in data1:
    print(d)
for d in data2:
    print(d)

for (k,v) in data1:
    print(&quot;k : &quot;,k,end=&quot; &quot;)
    print(&quot;v : &quot;,v)
</code></pre>
<blockquote>
</blockquote>
<p>(1, 2)
(3, 4)
(5, 6)
(1, 2)
(3, 4)
(5, 6)
k :  1 v :  2
k :  3 v :  4
k :  5 v :  6</p>
<h2 id="📒-range시작값끝값증가치">📒 range(시작값,끝값,증가치)</h2>
<p>숫자리스트를 생성하는 함수
<strong>시작값 ~ 끝값-1</strong></p>
<h3 id="📍-110까지-숫자-출력">📍 1~10까지 숫자 출력</h3>
<pre><code class="language-python">print( range(1,5,1) )
r=range(1,5,1)
print( type(r) )</code></pre>
<blockquote>
</blockquote>
<p>range(1, 5)
&lt;class &#39;range&#39;&gt;</p>
<pre><code class="language-python"># for + range
for i in range(1,5,1):
    print(i)

# 1~10 까지 숫자를 가로 출력
for i in range(1,11):
    print(i, end=&quot; &quot;)

# 1~10 까지 숫자 중에서 홀수만 출력
for i in range(1,11,2):
    print(i, end=&quot; &quot;)

# 10 ~ 1까지 숫자 가로 출력
for i in range(10,0,-1):
    print(i,end=&quot; &quot;)</code></pre>
<blockquote>
</blockquote>
<p>1
2
3
4
1 2 3 4 5 6 7 8 9 10
1 3 5 7 9 
10 9 8 7 6 5 4 3 2 1</p>
<h3 id="📍-for-누적합--110-누적합-계산하기">📍 for 누적합  (1~10 누적합 계산하기)</h3>
<pre><code class="language-python">sum = 0
for i in range(1,11):
    sum += i

print(&quot;sum : &quot;,sum)</code></pre>
<blockquote>
</blockquote>
<p>sum :  55</p>
<h3 id="📍-구구단-2단">📍 구구단 2단</h3>
<pre><code class="language-python">dan = 2
print(str(dan)+&quot;단&quot;)
for i in range(1,10):
    print(&quot; %d x %d = %d&quot; %(dan,i,dan * i) )</code></pre>
<blockquote>
</blockquote>
<p>2단
  2 x 1 = 2
 2 x 2 = 4
 2 x 3 = 6
 2 x 4 = 8
 2 x 5 = 10
 2 x 6 = 12
 2 x 7 = 14
 2 x 8 = 16
 2 x 9 = 18</p>
<h3 id="📍-구구단-25단-세로">📍 구구단 2~5단 (세로)</h3>
<pre><code class="language-python">print(&quot;구구단 2~4단 출력하기&quot;)

for dan in range(2,5,1):
    print(dan,&quot;단&quot;)
    for i in range(1,10,1):
        print(&quot; %d x %d = %d&quot; %(dan,i,dan * i) )</code></pre>
<blockquote>
</blockquote>
<p>구구단 2~4단 출력하기
2 단
 2 x 1 = 2
 2 x 2 = 4
 2 x 3 = 6
 2 x 4 = 8
 2 x 5 = 10
 2 x 6 = 12
 2 x 7 = 14
 2 x 8 = 16
 2 x 9 = 18
3 단
 3 x 1 = 3
 3 x 2 = 6
 3 x 3 = 9
 3 x 4 = 12
 3 x 5 = 15
 3 x 6 = 18
 3 x 7 = 21
 3 x 8 = 24
 3 x 9 = 27
4 단
 4 x 1 = 4
 4 x 2 = 8
 4 x 3 = 12
 4 x 4 = 16
 4 x 5 = 20
 4 x 6 = 24
 4 x 7 = 28
 4 x 8 = 32
 4 x 9 = 36</p>
<h3 id="📍-구구단-25단-가로">📍 구구단 2~5단 (가로)</h3>
<pre><code class="language-python">print(&quot;구구단 2~4단 출력하기&quot;)
for i in range(1,10,1):
    for dan in range(2,5,1):
        print(&quot; %d x %d = %d&quot; %(dan,i,dan * i), end=&quot;  &quot; )
    print()</code></pre>
<blockquote>
</blockquote>
<p>구구단 2~4단 출력하기
 2 x 1 = 2   3 x 1 = 3   4 x 1 = 4<br> 2 x 2 = 4   3 x 2 = 6   4 x 2 = 8<br> 2 x 3 = 6   3 x 3 = 9   4 x 3 = 12<br> 2 x 4 = 8   3 x 4 = 12   4 x 4 = 16<br> 2 x 5 = 10   3 x 5 = 15   4 x 5 = 20<br> 2 x 6 = 12   3 x 6 = 18   4 x 6 = 24<br> 2 x 7 = 14   3 x 7 = 21   4 x 7 = 28<br> 2 x 8 = 16   3 x 8 = 24   4 x 8 = 32<br> 2 x 9 = 18   3 x 9 = 27   4 x 9 = 36</p>
<h2 id="📒-리스트---for">📒 리스트 - for</h2>
<h3 id="📍-리스트-안에-for문-사용">📍 리스트 안에 for문 사용</h3>
<pre><code class="language-python">list2 = [1,2,3,4,5]
result = []

# 리스트안의 데이터를 각각 5씩 증가해서 추가

for i in list2:
    result.append(i+5)

print(result)</code></pre>
<blockquote>
</blockquote>
<p>[6, 7, 8, 9, 10]</p>
<h2 id="📒-리스트-안에-for문-사용">📒 리스트 안에 for문 사용</h2>
<ul>
<li>리스트 변수 = [ 표현식  for 값 in 반복객체 ]</li>
<li>리스트 변수 = [ 표현식  for 값 in 반복객체 if 조건]<h3 id="📍">📍</h3>
<pre><code class="language-python">result = [ (num+5) for num in list2 ]
print(result)
</code></pre>
</li>
</ul>
<p>result2 = [ (num*10) for num in list2 if num%2 == 0]
print(result2)</p>
<p>result = [ (num+5) for num in range(1,10,1) ]
print(result)</p>
<p>result3 = [ (x * y) for x in range(1,6,1)
                    for y in range(1,5,1)]</p>
<p>print(result3)</p>
<p>```</p>
<blockquote>
</blockquote>
<p>[6, 7, 8, 9, 10]
[6, 7, 8, 9, 10]
[20, 40]
[6, 7, 8, 9, 10, 11, 12, 13, 14]
[1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16, 5, 10, 15, 20]</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Python 3]]></title>
            <link>https://velog.io/@joy_all/Python-3</link>
            <guid>https://velog.io/@joy_all/Python-3</guid>
            <pubDate>Tue, 23 Mar 2021 01:49:08 GMT</pubDate>
            <description><![CDATA[<h2 id="📒-튜플tuple-자료형">📒 튜플(tuple) 자료형</h2>
<ul>
<li>( ) 사용해서 데이터를 저장</li>
<li>튜플의 데이터를 수정, 삭제 불가능(변경x)<pre><code class="language-python">t1 = ()
t2 =(1,)  # 튜플타입의 데이터를 1개만 생성할 경우 [,] 사용해야함(필수)
t2_1 =(1) # 콤마가 없을경우 int 타입
print(type(t2), type(t2_1))
</code></pre>
</li>
</ul>
<p>t3 = (1,2,3,4,5)
t4 = 1,2,3,4,5 # 튜플임 ( ) 생략가능 / 리스트는 [] 꼭 써야함
print(type(t4))</p>
<pre><code>&gt;
&lt;class &#39;tuple&#39;&gt; &lt;class &#39;int&#39;&gt;
&lt;class &#39;tuple&#39;&gt;

```python
t5 = (1,2,3,&#39;a&#39;,&#39;b&#39;)
t6 = (1,2,3,&#39;a&#39;,&#39;b&#39;,(1,2,3,4),[1,2,3,5])
print(t6)
print(t6[6][1])
t6[6][1] = 10
print(t6)</code></pre><blockquote>
</blockquote>
<p>(1, 2, 3, &#39;a&#39;, &#39;b&#39;, (1, 2, 3, 4), [1, 2, 3, 5])
2
(1, 2, 3, &#39;a&#39;, &#39;b&#39;, (1, 2, 3, 4), [1, 10, 3, 5])</p>
<ul>
<li>t6[6] = &quot;test&quot; 수정불가</li>
<li>print(t6)</li>
<li>del(t6[0])  삭제불가</li>
</ul>
<h3 id="📍-코드를-실행하면서-데이터를-여러개-저장">📍 코드를 실행하면서 데이터를 여러개 저장</h3>
<h4 id="값이-변경-가능---리스트-타입">값이 변경 가능 - 리스트 타입</h4>
<h4 id="값이-변경-불가---튜플-타입">값이 변경 불가 - 튜플 타입</h4>
<pre><code class="language-python">print(&quot;t3&quot;,t3)
print(t3[2]) # 데이터 사용가능 (인덱싱 가능)
print(t3[2:3]) # 슬라이싱 가능 -&gt; 튜플의 형태로 데이터 리턴</code></pre>
<blockquote>
</blockquote>
<p>t3 (1, 2, 3, 4, 5)
3
(3,)</p>
<h3 id="📍-튜플-연결">📍 튜플 연결(+)</h3>
<pre><code class="language-python">print(t3 + t4)
t5 = t3+t4
print(t5)
print(t3[0:2]+t4)</code></pre>
<blockquote>
</blockquote>
<p>(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
(1, 2, 1, 2, 3, 4, 5)</p>
<h3 id="📍-튜플-복사">📍 튜플 복사(*)</h3>
<pre><code class="language-python">print(t3 * 2)
print(t3[0:2] * 2)
# print(t3[0] * 2) 불가능</code></pre>
<blockquote>
</blockquote>
<p>(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
(1, 2, 1, 2)</p>
<h3 id="📍-튜플에-추가">📍 튜플에 추가</h3>
<pre><code class="language-python">print(&quot;길이 : &quot;, len(t3))
print(t3)
# t3 튜플에 6,7 추가
print(t3 +(6,7))
t3+=(8,9)
print( t3 )</code></pre>
<blockquote>
</blockquote>
<p>길이 :  5
(1, 2, 3, 4, 5)
(1, 2, 3, 4, 5, 6, 7)
(1, 2, 3, 4, 5, 8, 9)</p>
<h2 id="📒-딕셔너리-자료형-순차적접근-x">📒 딕셔너리 자료형 (순차적접근 x)</h2>
<ul>
<li>key값을 사용해서 value를 사용</li>
<li>key값은 변경 X, value값은 변경 O</li>
<li>key값은 중복데이터를 사용X (가장마지막의 key값만 불러다 사용가능)</li>
<li>key값 - 튜플(o), 리스트(x)</li>
<li>{ key:value, key:value,...}</li>
</ul>
<h3 id="📍">📍</h3>
<pre><code class="language-python">dic = { &quot;name&quot;:&quot;itwill&quot;,&quot;tel&quot;:&quot;0518030909&quot;,&quot;addr&quot;:&quot;부산진구&quot; }

print(dic)
#  레퍼런스[&#39; key값 &#39;]
print(&quot;dic[&#39;name&#39;] = &quot;,dic[&#39;name&#39;])

# 전화번호, 주소
print(dic[&quot;tel&quot;],dic[&quot;addr&quot;])

dic[&quot;addr&quot;] = &quot;부산진구 동천로109&quot;

print(dic[&quot;addr&quot;])</code></pre>
<blockquote>
</blockquote>
<p>{&#39;name&#39;: &#39;itwill&#39;, &#39;tel&#39;: &#39;0518030909&#39;, &#39;addr&#39;: &#39;부산진구&#39;}
dic[&#39;name&#39;] =  itwill
0518030909 부산진구
부산진구 동천로109</p>
<h3 id="📍-딕셔너리-타입에-데이터-추가">📍 딕셔너리 타입에 데이터 추가</h3>
<pre><code class="language-python"># dic[4]=&quot;0518030979&quot;
dic[&quot;fax&quot;]=&quot;0518030979&quot;   # fax 키값, 0518030979 value값  저장  {&quot;fax&quot;:&quot;0518030979&quot;}

print(dic)

# dic[&quot;classRoom&quot;] = [1,2,3,4,5,6,7]
dic[&quot;classRoom&quot;] = (1,2,3,4,5,6,7)

print(dic)</code></pre>
<blockquote>
</blockquote>
<p>{&#39;name&#39;: &#39;itwill&#39;, &#39;tel&#39;: &#39;0518030909&#39;, &#39;addr&#39;: &#39;부산진구 동천로109&#39;, &#39;fax&#39;: &#39;0518030979&#39;}
{&#39;name&#39;: &#39;itwill&#39;, &#39;tel&#39;: &#39;0518030909&#39;, &#39;addr&#39;: &#39;부산진구 동천로109&#39;, &#39;fax&#39;: &#39;0518030979&#39;, &#39;classRoom&#39;: (1, 2, 3, 4, 5, 6, 7)}</p>
<h3 id="📍-fax-정보-삭제">📍 fax 정보 삭제</h3>
<pre><code class="language-python">del( dic[&#39;fax&#39;] )
print(dic)
print( type(dic) )</code></pre>
<blockquote>
</blockquote>
<p>{&#39;name&#39;: &#39;itwill&#39;, &#39;tel&#39;: &#39;0518030909&#39;, &#39;addr&#39;: &#39;부산진구 동천로109&#39;, &#39;classRoom&#39;: (1, 2, 3, 4, 5, 6, 7)}
&lt;class &#39;dict&#39;&gt;</p>
<h3 id="📍-print-dic1---에러--딕셔너리-호출은-반드시-key값만-사용">📍 print( dic[1] )  에러  딕셔너리 호출은 반드시 key값만 사용</h3>
<pre><code class="language-python">dic[&quot;tel&quot;]=&quot;010-1234-1234&quot;
print(dic)

dic2= { &quot;k&quot;:&quot;125455&quot;, &quot;k&quot;:&quot;111111&quot;}

print( dic2[&quot;k&quot;] )</code></pre>
<blockquote>
</blockquote>
<p>{&#39;name&#39;: &#39;itwill&#39;, &#39;tel&#39;: &#39;010-1234-1234&#39;, &#39;addr&#39;: &#39;부산진구 동천로109&#39;, &#39;classRoom&#39;: (1, 2, 3, 4, 5, 6, 7)}
111111</p>
<h3 id="📍-key값만-가져오기">📍 key값만 가져오기</h3>
<pre><code class="language-python">print( dic.keys() )
print( type(dic.keys()) ) # &lt;class &#39;dict_keys&#39;&gt; 타입</code></pre>
<blockquote>
</blockquote>
<p>dict_keys([&#39;name&#39;, &#39;tel&#39;, &#39;addr&#39;, &#39;classRoom&#39;])
&lt;class &#39;dict_keys&#39;&gt;</p>
<h3 id="📍-class-dict_keys-타입---list-타입-변경후-사용">📍 &lt;class &#39;dict_keys&#39;&gt; 타입 -&gt; list 타입 변경후 사용</h3>
<pre><code class="language-python">ls = list( dic.keys() )
print( type(ls),ls )</code></pre>
<blockquote>
</blockquote>
<p>&lt;class &#39;list&#39;&gt;  [&#39;name&#39;, &#39;tel&#39;, &#39;addr&#39;, &#39;classRoom&#39;]</p>
<h3 id="📍-value-값만-가져오기">📍 value 값만 가져오기</h3>
<pre><code class="language-python">print(dic.values())
print( type(dic.values()))  # &lt;class &#39;dict_values&#39;&gt; 타입</code></pre>
<blockquote>
</blockquote>
<p>dict_values([&#39;itwill&#39;, &#39;010-1234-1234&#39;, &#39;부산진구 동천로109&#39;, (1, 2, 3, 4, 5, 6, 7)])
&lt;class &#39;dict_values&#39;&gt;</p>
<h3 id="📍-keyvalue-쌍으로-가져오기">📍 key,value 쌍으로 가져오기</h3>
<pre><code class="language-python">print( dic.items() )
print( type(dic.items()))  # &lt;class &#39;dict_items&#39;&gt; 타입

dic.clear()
print( dic )
# print( dic[&#39;name&#39;] ) 에러 (key값이 없기 때문)</code></pre>
<blockquote>
</blockquote>
<p>dict_items([(&#39;name&#39;, &#39;itwill&#39;), (&#39;tel&#39;, &#39;010-1234-1234&#39;), (&#39;addr&#39;, &#39;부산진구 동천로109&#39;), (&#39;classRoom&#39;, (1, 2, 3, 4, 5, 6, 7))])
&lt;class &#39;dict_items&#39;&gt;
{}</p>
<h3 id="📍-딕셔너리-안에-key값이-있는지-체크">📍 딕셔너리 안에 key값이 있는지 체크</h3>
<pre><code class="language-python">print(&#39;name&#39; in dic )

if &#39;name&#39; in dic:
    print(&quot;key값이 있습니다&quot;,dic[&#39;name&#39;])
else:
    print(&quot;key값이 없습니다. (key 생성)&quot;)
    dic[&quot;name&quot;]=&quot;&quot;

print(dic)</code></pre>
<blockquote>
</blockquote>
<p>False
key값이 없습니다. (key 생성)
{&#39;name&#39;: &#39;&#39;}</p>
<h3 id="📍-딕셔너리의-값이-있는지-없는지-확인">📍 딕셔너리의 값이 있는지 없는지 확인</h3>
<pre><code class="language-python">dic[&quot;tel&quot;]=&quot;010-1234-1234&quot;

print( dic.get(&quot;없는키&quot;) )  # 없는 key =&gt; None 리턴
print( dic.get(&quot;tel&quot;) )   # 있는 key =&gt; key에 해당하는 value를 리턴
# print( dic[&quot;addr&quot;] ) -&gt; key에러 발생</code></pre>
<blockquote>
</blockquote>
<p>None
010-1234-1234</p>
<h2 id="📒-집합-자료형-set-23-이후-지원">📒 집합 자료형 (set) 2.3~ 이후 지원</h2>
<ul>
<li>데이터 중복 x, 데이터를 순서 없이 저장</li>
<li>=&gt; 인덱싱을 사용할수 없음<h3 id="📍-1">📍</h3>
<pre><code class="language-python">s1 = set([1,2,3,4,5])
print(s1, type(s1))
</code></pre>
</li>
</ul>
<p>s2 = set(&quot;itwill&quot;)
print(s2,type(s2))</p>
<h1 id="print-s10---순서가-없기-때문에-인덱싱-x">print( s1[0] )  순서가 없기 때문에 인덱싱 X</h1>
<h1 id="-리스트튜플로-변경후-사용">=&gt; 리스트/튜플로 변경후 사용</h1>
<p>l1 = list(s1)
print(l1[0])
t1 = tuple(s2)
print(t1[1])</p>
<pre><code>&gt;
{1, 2, 3, 4, 5} &lt;class &#39;set&#39;&gt;
{&#39;i&#39;, &#39;l&#39;, &#39;w&#39;, &#39;t&#39;} &lt;class &#39;set&#39;&gt;
1
t

### 📍 자료형의 T/F
```python
 문자열 - &quot;test&quot; (T) , &quot;&quot; (F)
 리스트 - [1,2] (T), [] (F)
 튜플 -  () (F)
 딕셔너리 - {} (F)
 숫자 -  0이 아닌숫자 (T), 0 (F)
        None (F)</code></pre><pre><code class="language-python">ls = [1,2,3,4]
#  id(객체) -&gt; 객체의 메모리 주소
print( ls , id(ls))

ls2 = ls

print( id(ls2), id(ls))
#  A  is  B  : A와 B가 동일한 객체 인가? 물어보는 연산자 is
print( ls is ls2 )

from copy import copy

a = copy(ls2)

print(a, id(a),id(ls2))</code></pre>
<blockquote>
</blockquote>
<p>[1, 2, 3, 4] 2604960319936
2604960319936 2604960319936
True
[1, 2, 3, 4] 2604960380800 2604960319936</p>
<h3 id="📍-변수-생성하기">📍 변수 생성하기</h3>
<pre><code class="language-python">a,b = ( &#39;1&#39;,&#39;2&#39; )
(a,b) = ( &#39;1&#39;,&#39;2&#39; )
[aa,bb] =[11,22]
a=b=100

a=100
b=200

a,b = b,a

print(a,b)</code></pre>
<blockquote>
</blockquote>
<p>200 100</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[프레임 워크 시작하기! <기초2>]]></title>
            <link>https://velog.io/@joy_all/%ED%94%84%EB%A0%88%EC%9E%84-%EC%9B%8C%ED%81%AC-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-%EA%B8%B0%EC%B4%882</link>
            <guid>https://velog.io/@joy_all/%ED%94%84%EB%A0%88%EC%9E%84-%EC%9B%8C%ED%81%AC-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-%EA%B8%B0%EC%B4%882</guid>
            <pubDate>Mon, 22 Mar 2021 08:02:02 GMT</pubDate>
            <description><![CDATA[<h2 id="📒-spring">📒 Spring</h2>
<h3 id="java-기반의-웹-어플리케이션을-개발하기-위한-오픈소스-프레임워크-경량-프레임워크--경량-컨테이너">java 기반의 웹 어플리케이션을 개발하기 위한 오픈소스 프레임워크 (경량 프레임워크 / 경량 컨테이너)</h3>
<h4 id="프레임워크--어떤-대상을-구성하는-틀-뼈대">프레임워크 : 어떤 대상을 구성하는 틀, 뼈대</h4>
<p>✔ SW적인 의미 : 기능을 미리 클래스,인터페이스 형태로 만들어놓은 제품
✔ 어느정도 완성되어있는 파일을 조합해서 개발
✔ ex) spring, Android, Jqeury</p>
<h3 id="📕-컨테이너">📕 컨테이너</h3>
<p>톰캣(서블릿 컨테이너)- 서블릿 생성,초기화,서비스실행,소멸..(서블릿에 관한 모든 권한을 가지고있기때문)</p>
<h3 id="📕-ejb-프레임워크enterprise-java-beans">📕 EJB 프레임워크(Enterprise Java Beans)</h3>
<p>기업 환경 시스템을 구현하기 위한 서버쪽 모델, 애플리케이션 비지니스 로직을 포함하는 서버 어플리케이션 -&gt; 무거운 프레임워크</p>
<h3 id="📕-스프링-특징">📕 스프링 특징</h3>
<p>✔ EJB 보다 가볍고, 배우기쉬운 경량 컨테이너</p>
<p>✔ 제어 역행 (IoC, Inversion of Control) 기술을 사용해서 애플리케이션 간의 느슨한 결합을 제어.
✔ <strong>&quot;메서드, 객체의 호출을 개발자가 결정 x, 외부(spring)에서 결정&quot;</strong></p>
<p>✔ 의존성 주입(DI, Dependency Injection) 지원함.
✔ <strong>&quot;의존적인 객체를 직접 생성, 제어하는 것이 아니라, 제어의 역행(IoC)으로 특정 객체에 필요한 객체를 외부에서 만들어서 연결&quot;</strong></p>
<p>✔ 관점지향 (AOP, Aspect-Oriented Programming)을 사용하여 자원관리
✔ <strong>핵심 기능들과 부수적인 기능들을 분리해서 모듈성을 증가</strong></p>
<p>✔ 영속성과 다양한 서비스를 지원 (DB)
✔ 수많은 라이브러리를 제공</p>
<p>프레임워크가 마트!, 내가 필요한 것들을 꺼내 쓸수 있음!</p>
<h3 id="📕-스프링-프레임워크-주요기능">📕 스프링 프레임워크 주요기능</h3>
<ul>
<li>Spring <strong>Core</strong> : 다른 기능과 설정을 분리하기 위한 IoC 기능을 제공</li>
<li>Spring <strong>Context</strong> : 기본기능, 각 기능을 표현하는 Bean에 대한 접근 방법 제공</li>
<li>Spring <strong>DAO</strong> : JDBC 기능을 조금더 편리하게 사용가능</li>
<li>Spring <strong>ORM</strong> :  하이버네이트, 마이바티스와 같은 영속성(DB) 관련 프레임워크 연동제공</li>
<li>Spring <strong>AOP</strong> : 관점지향 프로그래밍 지원</li>
<li>Spring <strong>Web</strong> : 웹 애플리케이션에 필요한 기능 지원</li>
<li>Spring <strong>WebMVC</strong> : 스프링에서 MVC 구현에 필요한 기능 지원</li>
</ul>
<h2 id="📒-프로젝트-선택기준">📒 프로젝트 선택기준</h2>
<p>✔ WAS를 사용해본 경험이 있는가? (Tomcat)
✔ 스프링을 써본적이 있는가?
✔ Model2 방식 개발을 경험한적 있는가?
✔ WAS 실행시 에러 처리경험이 있는가?</p>
<p>▶ <strong>YES : Spring Legacy Project</strong></p>
<ul>
<li>거의 모든 스프링 웹페이지</li>
<li>공부할 자료가 많음(구글링자료)</li>
<li>기존의 프로젝트 이해가 쉬움</li>
<li>모든 버전의 스프링 사용가능</li>
<li>초반 설정이 어려움</li>
<li>WAS에서 많은 리소스필요함</li>
</ul>
<p>▶ <strong>NO : Spring Starter Project (boot-업데이트 및 최신트렌드 적용)</strong></p>
<ul>
<li>별도의 설정이 필요없음</li>
<li>WAS도 필요없음 (자체 서버 제공)</li>
<li>로딩시간이 짧음(상대적으로 적은 리소스 필요)</li>
<li>기존의 설정과 다른방식 </li>
<li>jsp설정이 필요함.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[프레임 워크 시작하기! <기초>]]></title>
            <link>https://velog.io/@joy_all/%ED%94%84%EB%A0%88%EC%9E%84-%EC%9B%8C%ED%81%AC-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-%EA%B8%B0%EC%B4%88</link>
            <guid>https://velog.io/@joy_all/%ED%94%84%EB%A0%88%EC%9E%84-%EC%9B%8C%ED%81%AC-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-%EA%B8%B0%EC%B4%88</guid>
            <pubDate>Mon, 22 Mar 2021 08:00:24 GMT</pubDate>
            <description><![CDATA[<h3 id="🔨프레임-워크-툴-다운로드">🔨프레임 워크 툴 다운로드</h3>
<p><a href="https://spring.io/tools">https://spring.io/tools</a>
<img src="https://images.velog.io/images/joy_all/post/6aa1645d-6728-48a7-970b-2db8d5154692/121.PNG" alt="">
위의 사이트에서 파일 다운로드.</p>
<p><img src="https://images.velog.io/images/joy_all/post/54bbe3fe-5a41-442e-ab0c-1ff55df9ca73/1234.png" alt="">
처음 시작시 Help의 이클립스 마켓에서
<img src="https://images.velog.io/images/joy_all/post/d7689a1b-7428-4a01-b1a4-404473fdde8a/12345.png" alt="">
STS 검색 후 String Tools 3 Add-on for Spring Tools 4 3.9.16.RELEASE 설치!
<img src="https://images.velog.io/images/joy_all/post/742debb2-861a-41d5-9411-703d22406766/123456.png" alt=""></p>
<p><img src="https://images.velog.io/images/joy_all/post/9f6895bc-b6ae-4c70-bcb2-387f9c3e3b7c/image.png" alt="">
스프링으로 설정</p>
<p>Spring Legacy Project 클릭
<img src="https://images.velog.io/images/joy_all/post/0ea8f26f-99b2-4e67-9ef3-9a2cbb3ba458/1111.PNG" alt="">
프로젝트 네임 입력 후
Spring MVC Project 선택 후 Next 클릭
<img src="https://images.velog.io/images/joy_all/post/c35c86f8-400b-4953-81b8-176c88272c87/123123.PNG" alt="">
패키지 명 작성 후 완료</p>
<h4 id="window---preferences-기본설정">window -&gt; preferences 기본설정</h4>
<p><img src="https://images.velog.io/images/joy_all/post/e0333ac4-2820-46e4-a416-f8e0716d5c4d/as.PNG" alt="">
<img src="https://images.velog.io/images/joy_all/post/9b9e76e2-a90c-4961-a1af-a451adba03f6/sfa.PNG" alt=""></p>
<p><img src="https://images.velog.io/images/joy_all/post/16ff480f-6306-483b-9ee4-4fa0a3715478/rqwr.png" alt="">
<img src="https://images.velog.io/images/joy_all/post/bbab9b3a-86e8-4d30-91ac-6aa754b3719f/asfg.PNG" alt="">
<img src="https://images.velog.io/images/joy_all/post/a4f1c116-0ea7-48c5-8f47-b8b4c0fda8ec/jfd.PNG" alt="">
<img src="https://images.velog.io/images/joy_all/post/78f4d461-1146-4ca7-a479-47d44b21f36d/jre.PNG" alt=""></p>
<p>pom.xml 파일에서 자바 버전을 1.8, 스프링 프레임워크 버전을 4.3.8로 변경 후 저장
<img src="https://images.velog.io/images/joy_all/post/b1f7eba2-8b6a-4852-b783-2ebb2b847697/221.PNG" alt=""></p>
<p><strong>프로젝트명에서 마우스 우클릭으로 Properties 선택</strong>
자바 1.6 제거 후
<img src="https://images.velog.io/images/joy_all/post/98431981-47d0-4ebd-a03e-a899f661ad50/333.png" alt="">
add library로 jre 추가
<img src="https://images.velog.io/images/joy_all/post/5249d2ea-df21-4c00-ab6a-dc14439d9945/dsg.PNG" alt="">
자바 버전 1.8로 올려줌
java compiler도 같이 1.8로 올려줌
<img src="https://images.velog.io/images/joy_all/post/611886da-94be-464d-ad8f-e48bb3f5cf06/dfjhfdj.PNG" alt=""></p>
<h2 id="📒-pomxml과-maven-dependencies-연결">📒 pom.xml과 Maven Dependencies 연결</h2>
<h3 id="🔨maven-repository-빌드도구">🔨Maven repository 빌드도구</h3>
<p><a href="https://mvnrepository.com/">https://mvnrepository.com/</a></p>
<p>sql 검색 후</p>
<p>MySQL Connector/J » 5.1.47 버전
<img src="https://images.velog.io/images/joy_all/post/046fd2b9-95eb-4186-9f08-60e695b03051/akak.PNG" alt="">
Maven 복사 후
pom.xml 파일에 
&lt;<d>dependency&gt;
  사이에 붙여넣기
&lt;<d>/dependency&gt;
<img src="https://images.velog.io/images/joy_all/post/0b28fed6-0290-4ba9-b227-7b4e45db4f67/maven.PNG" alt="">
하면 Maven Dependencies 에 삽입되어 있음. </p>
<h2 id="📒-서버-시작하기">📒 서버 시작하기</h2>
<p><img src="https://images.velog.io/images/joy_all/post/96dfd04e-32a0-4023-a58e-12c6129e1b2a/121212.PNG" alt="">
톰캣 8.5 선택</p>
<p><img src="https://images.velog.io/images/joy_all/post/4a1a7edf-30cd-452e-b890-274633359ae6/image.png" alt="">
  add and remove에서 왼쪽에서 오른쪽으로 추가하기</p>
<p><img src="https://images.velog.io/images/joy_all/post/588b8e13-0090-4518-9720-47a51cff806d/image.png" alt="">
이렇게 떠야, 사용가능한 상태</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Python 시작2]]></title>
            <link>https://velog.io/@joy_all/Python-%EC%8B%9C%EC%9E%912</link>
            <guid>https://velog.io/@joy_all/Python-%EC%8B%9C%EC%9E%912</guid>
            <pubDate>Fri, 19 Mar 2021 10:48:12 GMT</pubDate>
            <description><![CDATA[<h1 id="📒제어문-if">📒제어문 if</h1>
<ul>
<li>if 제어문에서는 실행코드는 들여쓰기를 해야함(1칸이상)</li>
<li>space 4칸 =&gt; tab 1칸</li>
</ul>
<pre><code class="language-python">if 10&gt;2:
    print(&quot;참&quot;)</code></pre>
<blockquote>
</blockquote>
<p>참</p>
<ul>
<li>조건문 : 참, 거짓결과를 확인가능 구문</li>
<li>== != &gt; &gt;= &lt; &lt;=</li>
<li>비교연산자의 결과는 항상 boolean</li>
</ul>
<h3 id="📍time--9">📍time = 9</h3>
<h3 id="9시일때-학원을-간다9시이전-안간다9시이후">9시일때 학원을 간다(9시이전), 안간다(9시이후)</h3>
<pre><code class="language-python">time = input(&quot;시간입력 : &quot;)

if int(time) &gt;= 9:
    print(&quot;안간다&quot;)
else:
    print(&quot;간다&quot;)</code></pre>
<ul>
<li><p>int(), float(), str()</p>
</li>
<li><p>숫자가 아닌데이터를 숫자로 변경시 오류</p>
<pre><code class="language-python">int(10)
int(&quot;100&quot;)
#int(&quot;hello&quot;)
int(3.1234)</code></pre>
</li>
<li><p>int(&quot;3.123&quot;) &quot;소수점이 포함된 숫자&quot;</p>
</li>
<li><p>type(값) : 해당 데이터의 타입을 리턴</p>
<pre><code class="language-python">if 100&gt;50:
  print(&quot;참1&quot;)
  print(&quot;참2&quot;)
  if 100&gt;30:
      print(&quot;참3&quot;)</code></pre>
</li>
<li><p>조건문에서 사용가능한 연산자</p>
</li>
<li><p>and(둘다 참일때), or(둘중에 하나라도 참일때), not(부정)</p>
</li>
<li><p>if 100&gt;0 and 200&gt;0:</p>
</li>
<li><p>if 100&gt;0 or 200&lt;0:</p>
<h3 id="📍-만약에-5천원-이상-이면서-카드가-있으면-택시를-타고">📍 만약에 5천원 이상 이면서, 카드가 있으면 &quot;택시를 타고&quot;</h3>
<h3 id="5천원-미만이거나-카드가-없으면-버스를-탄다">5천원 미만이거나, 카드가 없으면 &quot;버스를 탄다&quot;</h3>
<pre><code class="language-python">card = True;
money = 3000;
</code></pre>
</li>
</ul>
<p>if money&gt;=5000 and card:
    print(&quot;택시를 탄다&quot;)
else:
    print(&quot;버스를 탄다&quot;)</p>
<pre><code>### 📍A가 B안에 있는지 없는지 비교 연산 =&gt; T/F
- if제어문에서 아무런 동작없이 넘어가기 위해서는 [pass] 문법 사용
- A in B // A not in B
```python
print( 1 in [1,2,3,4,5] )
print( 6 not in [1,2,3,4,5] )
print( &#39;a&#39; in &#39;itwill busan&#39;  )</code></pre><blockquote>
</blockquote>
<p>True
True
True</p>
<h3 id="📍문자안에-a-있을경우-있다">📍문자안에 a 있을경우 &quot;있다&quot;</h3>
<h3 id="없을경우-없다">없을경우 &quot;없다&quot;</h3>
<pre><code class="language-python">str1 = &quot;itwill busan class&quot;

if &#39;a&#39; in str1:
    print(&quot;있다&quot;)
else:
    print(&quot;없다&quot;)


if str1.find(&quot;busan&quot;)&gt;0:
    print(&quot;있다&quot;)</code></pre>
<blockquote>
</blockquote>
<p>있다
있다</p>
<h3 id="📍학생-성적-출력">📍학생 성적 출력</h3>
<ul>
<li>학생의 성적 입력받아서 input() 학점으로 변경후 출력</li>
<li>100<del>90 : A, 89</del>80 : B, 79<del>70:C,69</del>60:D, 59~0:F<pre><code class="language-python">score = int(input(&quot;성적을 입력하세요&gt;&gt;&quot;))
print(&quot;성적 &quot;,score,&quot;점&quot;)
</code></pre>
</li>
</ul>
<p>if 90 &lt;= score and score &lt;=100:
    print(&quot;A등급&quot;)
elif 80 &lt;= score &lt;=89:
    print(&quot;B등급&quot;)
elif 70 &lt;= score &lt;=79:
    print(&quot;C등급&quot;)
elif 60 &lt;= score &lt;=69:
    print(&quot;D등급&quot;)
elif 0 &lt;= score &lt;=59:
    print(&quot;F등급&quot;)
else:
    print(&quot;에러&quot;)</p>
<pre><code>
### 📍조건부 표현식 : 제어문 코드를 간결하게 표현
```python
if 10 &gt; 0:
    tmp =&quot;pass&quot;
else:
    tmp=&quot;pass&quot;</code></pre><h3 id="📍참일때값-if-조건문-else-거짓일때값">📍[참일때값] if 조건문 else [거짓일때값]</h3>
<pre><code class="language-python">tmp = &quot;pass&quot; if 10&gt;0 else &quot;pass&quot;</code></pre>
<h1 id="📒리스트-자료형">📒리스트 자료형</h1>
<ul>
<li>배열과 유사하게 데이터를 저장</li>
<li>변수 = [요소,요소,요소,....]<pre><code class="language-python">ls  = []
ls2 = [1,2,3,4,5,6]  #숫자
ls3 = [&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;] #문자
ls4 = [1,2,&#39;a&#39;,&#39;b&#39;] #숫자+문자
ls5 = [1,2,&#39;a&#39;,&#39;b&#39;,[1,2]] #숫자+문자+리스트
</code></pre>
</li>
</ul>
<p>print( type(ls) )
print( ls )
print( ls2 )</p>
<pre><code>&gt;
&lt;class &#39;list&#39;&gt;
[ ]
[1, 2, 3, 4, 5, 6]

### 📍리스트의 인덱스 정보 출력
```python
print(&quot;ls2 리스트의 3번 인덱스 값&quot;,ls2[3])
print(ls2[-1],&quot; // &quot;,ls2[-4])
# 인덱스 번호 양수(왼쪽에서 0부터 시작), 음수(오른쪽에서 -1부터 시작)
print(ls2[3] + ls2[4])

print(ls4)
# print(ls4[0]+ls4[-1])
print(str(ls4[0])+ls4[-1])</code></pre><blockquote>
</blockquote>
<p>ls2 리스트의 3번 인덱스 값 4
6  //  3
9
[1, 2, &#39;a&#39;, &#39;b&#39;]
1b</p>
<h3 id="📍이중리스트의-값을-접근하는-방법">📍이중리스트의 값을 접근하는 방법</h3>
<pre><code class="language-python">print(ls5)
print(ls5[1], ls5[4], ls5[4][1])</code></pre>
<blockquote>
</blockquote>
<p>[1, 2, &#39;a&#39;, &#39;b&#39;, [1, 2]]
2 [1, 2] 2</p>
<h3 id="📍리스트의-접근방법---리스트도-타입객체">📍리스트의 접근방법 -&gt; 리스트도 타입(객체)</h3>
<pre><code class="language-python">ls6=[ 1,2,[1,2,[1,2]]]

print( ls6[2][2][1] )

print(&quot;리스트의 길이 :&quot;, len(ls2))
print(&quot;값의 개수 : &quot;,ls6.count(1))
print(&quot;값의 개수 : &quot;,ls6[2].count(1))</code></pre>
<blockquote>
</blockquote>
<p>2
리스트의 길이 : 6
값의 개수 :  1
값의 개수 :  1</p>
<h1 id="📒리스트-슬라이싱">📒리스트 슬라이싱</h1>
<h3 id="📍ls2--3번5번-인덱스-값만-출력">📍ls2  3번~5번 인덱스 값만 출력</h3>
<pre><code class="language-python">print(ls2)
print( ls2[3:6] )  #문자열 슬라이싱과 동일 [시작:끝-1]
print( ls2[:])
print( ls2[2:])
print( ls2[:2] )</code></pre>
<blockquote>
</blockquote>
<p>[1, 2, 3, 4, 5, 6]
[4, 5, 6]
[1, 2, 3, 4, 5, 6]
[3, 4, 5, 6]
[1, 2]</p>
<h3 id="📍리스트-연산">📍리스트 연산</h3>
<pre><code class="language-python">print( ls2 + ls3 )  #리스트 연결
# print( ls2 - ls3 )  에러
print( ls2 * 3 )  #리스트 반복하기</code></pre>
<blockquote>
</blockquote>
<p>[1, 2, 3, 4, 5, 6, &#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;]
[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]</p>
<h3 id="📍리스트-데이터-수정">📍리스트 데이터 수정</h3>
<pre><code class="language-python">ls_a = [1,2,3]
print( ls_a[1] )
ls_a[1] = 100
print( ls_a[1] )</code></pre>
<blockquote>
</blockquote>
<p>2
100</p>
<h3 id="📍리스트요소-삭제">📍리스트요소 삭제</h3>
<pre><code class="language-python">del ls_a[1]
print(ls_a)
# ls_a = ls_a * 3
ls_a *= 3
print(ls_a)
del ls_a[2:4]
print(ls_a)</code></pre>
<blockquote>
</blockquote>
<p>[1, 3]
[1, 3, 1, 3, 1, 3]
[1, 3, 1, 3]</p>
<h3 id="📍ls_a4--100-데이터-추가-x">📍ls_a[4] = 100 (데이터 추가 x)</h3>
<pre><code class="language-python">ls_a.append(100)  #데이터 추가O

print(ls_a)</code></pre>
<blockquote>
</blockquote>
<p>[1, 3, 1, 3, 100]</p>
<h3 id="📍12345-데이터를-기존의-리스트에-추가">📍1,2,3,4,5 데이터를 기존의 리스트에 추가</h3>
<pre><code class="language-python">ls_a.append([1,2,3,4,5])

print(ls_a)</code></pre>
<blockquote>
</blockquote>
<p>[1, 3, 1, 3, 100, [1, 2, 3, 4, 5]]</p>
<h3 id="📍sort--오름차순-정렬숫자알파벳-reverse--리스트-뒤집기">📍sort() : 오름차순 정렬(숫자,알파벳), reverse() : 리스트 뒤집기</h3>
<h3 id="📍-insertab--요소-삽입--a인덱스에-b의-값을-넣는다">📍 insert(a,b) : 요소 삽입  a인덱스에 b의 값을 넣는다.</h3>
<ul>
<li>print(ls_a.sort()) #동일 데이터의 경우 정렬 불가능<pre><code class="language-python">ls_b = [1,2,3,6,4,5,7,8,9]
ls_b.insert(4,10)
</code></pre>
</li>
</ul>
<p>print(ls_b)</p>
<pre><code>&gt;
[1, 2, 3, 6, 10, 4, 5, 7, 8, 9]

### 📍del 값 , del(값), 리스트 요소 제거 remove(값)
```python
ls_b.remove(10)
print(ls_b)

ls_b = ls_b * 2
print(ls_b)

# del() / remove()
del (ls_b[3])
print(ls_b)

ls_b.remove(5)
print(ls_b)
ls_b.remove(5)
print(ls_b)</code></pre><blockquote>
</blockquote>
<p>[1, 2, 3, 6, 4, 5, 7, 8, 9]
[1, 2, 3, 6, 4, 5, 7, 8, 9, 1, 2, 3, 6, 4, 5, 7, 8, 9]
[1, 2, 3, 4, 5, 7, 8, 9, 1, 2, 3, 6, 4, 5, 7, 8, 9]
[1, 2, 3, 4, 7, 8, 9, 1, 2, 3, 6, 4, 5, 7, 8, 9]
[1, 2, 3, 4, 7, 8, 9, 1, 2, 3, 6, 4, 7, 8, 9]</p>
<h3 id="📍pop--리스트-가장-마지막의-데이터를-꺼내기-삭제">📍pop() : 리스트 가장 마지막의 데이터를 꺼내기 (삭제)</h3>
<pre><code class="language-python">ls_b.pop()

print(ls_b)
ls_b.pop(3)  # ls_b[3]요소를 삭제

print(ls_b)</code></pre>
<blockquote>
</blockquote>
<p>[1, 2, 3, 4, 7, 8, 9, 1, 2, 3, 6, 4, 7, 8]
[1, 2, 3, 7, 8, 9, 1, 2, 3, 6, 4, 7, 8]</p>
<h3 id="📍ls_bappend1234-x">📍ls_b.append(1,2,3,4) (x)</h3>
<pre><code class="language-python">ls_b.append([1, 2, 3, 4])
print(ls_b)
ls_b.pop()

ls_b.extend([1, 2, 3, 4])  # 리스트 + 리스트  / 리스트 += 리스트
print(ls_b)</code></pre>
<blockquote>
</blockquote>
<p>[1, 2, 3, 7, 8, 9, 1, 2, 3, 6, 4, 7, 8, [1, 2, 3, 4]]
[1, 2, 3, 7, 8, 9, 1, 2, 3, 6, 4, 7, 8, 1, 2, 3, 4]</p>
<ul>
<li>in연산자, not in연산자</li>
<li>=&gt; 주로 리스트와 같이 사용<h3 id="📍주머니에-전화기가-있으면-전화-없으면-집으로-돌아가기">📍주머니에 전화기가 있으면 &quot;전화&quot; 없으면 &quot;집으로 돌아가기&quot;</h3>
<pre><code class="language-python">pocket = [&#39;phone&#39;, &#39;money&#39;, &#39;paper&#39;]
if &#39;phone&#39; in pocket:
  print(&quot;전화&quot;)
if &#39;phone&#39; not in pocket:
  print(&quot;집으로 돌아가기&quot;)</code></pre>
<blockquote>
</blockquote>
전화</li>
</ul>
<h1 id="📒다차원-리스트">📒다차원 리스트</h1>
<h3 id="📍행---학생--각-학생별-총점--평균">📍행 - 학생 : 각 학생별 총점 / 평균</h3>
<pre><code class="language-python">score = [
    [90, 79, 56],
    [78, 97, 66],
    [40, 80, 70]
]

print(&quot;1번 학생 총점:&quot;,score[0][0]+score[0][1]+score[0][2],
&quot;,평균 :&quot;,score[0][0]+score[0][1]+score[0][2]/len(score[0]))
# print(&quot;2번 학생 총점:&quot;,,&quot;, 평균 :&quot;,)
# print(&quot;3번 학생 총점:&quot;,,&quot;, 평균 :&quot;,)
# 열 - 과목 : 각 과목별 총점 / 평균</code></pre>
<blockquote>
</blockquote>
<p>1번 학생 총점: 225 , 평균 : 187.66666666666666</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Python 시작1]]></title>
            <link>https://velog.io/@joy_all/Python-%EC%8B%9C%EC%9E%911</link>
            <guid>https://velog.io/@joy_all/Python-%EC%8B%9C%EC%9E%911</guid>
            <pubDate>Wed, 10 Mar 2021 08:32:20 GMT</pubDate>
            <description><![CDATA[<h2 id="🔨python-파이썬-설치">🔨Python 파이썬 설치</h2>
<p><a href="https://www.python.org/downloads/">https://www.python.org/downloads/</a></p>
<h2 id="🔨pycharm-파이참-설치">🔨PyCharm 파이참 설치</h2>
<p><a href="https://www.jetbrains.com/pycharm/">https://www.jetbrains.com/pycharm/</a></p>
<h3 id="📍-파이썬-2x-3x-버전의-차이점">📍 파이썬 2.x, 3.x 버전의 차이점</h3>
<ul>
<li>2버전의 경우 int형 나누기의 결과가 int형
3버전으로 int형 나누기 결과가 float형</li>
<li>3버전 : 모든 변수는 데이터를 객체로 처리(Object)</li>
<li>3버전 : 문자열 데이터를 유니코드로 표현</li>
</ul>
<h1 id="📒파이썬-run-실행하기단축키">📒파이썬 RUN 실행하기(단축키)</h1>
<p>shift + F10 기본 프로젝트 실행
ctrl + shift + F10 현재의 프로젝트 실행
alt + shift + F10 실행할 프로젝트 선택가능</p>
<h3 id="📍주석">📍주석</h3>
<p>ctrl + /</p>
<h3 id="📍여러줄-주석문">📍여러줄 주석문!</h3>
<p>&quot;&quot;&quot;
안녕
&quot;&quot;&quot;</p>
<h3 id="📍단축키-변경법">📍단축키 변경법</h3>
<p>file -&gt; Setting -&gt; Keymap</p>
<h1 id="📒식별자-선언">📒식별자 선언</h1>
<ul>
<li>예약어를 사용할 수 없음.</li>
<li>특수문자는 (_)언더바 만 사용가능</li>
<li>숫자로 시작할 수 없음</li>
<li>공백을 포함x</li>
<li>영문자를 사용해서 처리(대소문자 구분)</li>
</ul>
<p>💡ItBusan : 카멜 표기법 (이름의 시작, 연결되는 단어의 시작은 대문자로!)
💡it_busan : 스네이크 표기법</p>
<ul>
<li>카멜표기법(대문자로 시작) -&gt; 클래스</li>
<li>스네이크표기법(소문자로 시작) -&gt; (o)함수 (x)변수</li>
</ul>
<h1 id="📒파이썬-예약어-목록-확인">📒파이썬 예약어 목록 확인</h1>
<p>import keyword
print(keyword.kwlist)</p>
<blockquote>
<p>출력되는 목록 :
‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘async’, ‘await’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘nonlocal’, ‘not’, ‘or’, ‘pass’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’</p>
</blockquote>
<h1 id="📒파이썬-출력">📒파이썬 출력</h1>
<p>print(&quot;안녕하세요&quot;)
print(1000)
print(4.356)</p>
<blockquote>
<p>출력
안녕하세요
1000
4.356</p>
</blockquote>
<h3 id="📍여러개의-데이터-출력">📍여러개의 데이터 출력</h3>
<p>print(&quot;안녕하세요&quot;,&quot;저는&quot;,&quot;사용자&quot;,&quot;입니다&quot;)
print(&quot;te\nst&quot;)
print(&quot;Mary&#39;s cosmatics&quot;)
-&gt; print(&#39;Mary&#39;s cosmatics&#39;) (x)</p>
<blockquote>
</blockquote>
<p>안녕하세요 저는 사용자 입니다
te
st
Mary&#39;s cosmatics</p>
<h3 id="📍홍길동이-인사를-합니다-안녕하세요">📍홍길동이 인사를 합니다. &quot;안녕하세요&quot;</h3>
<p>print(&#39;홍길동이 인사를 합니다. &quot;안녕하세요&quot;&#39;)
print(&quot;홍길동이 인사를 합니다. &quot;안녕하세요&quot;&quot;)
print(&quot;홍길동이 인사를 합니다.\n &quot;안녕하세요&quot;&quot;)</p>
<blockquote>
</blockquote>
<p>홍길동이 인사를 합니다. &quot;안녕하세요&quot;
홍길동이 인사를 합니다. &quot;안녕하세요&quot;
홍길동이 인사를 합니다.
 &quot;안녕하세요&quot;</p>
<h3 id="📍문자-출력시">📍문자 출력시</h3>
<p>print(&quot;C:C:\Users\ITWILL\AppData\Local\Programs\Python\Python39&quot;)
print(&quot;data!data!data!&quot;)
print(&quot;data!&quot;,&quot;data!&quot;,&quot;data!&quot;)
print(&quot;data&quot;,&quot;data&quot;,&quot;data&quot;)
print(&quot;data&quot;,&quot;data&quot;,&quot;data&quot;,sep=&quot;!&quot;)</p>
<blockquote>
</blockquote>
<p>C:C:\Users\ITWILL\AppData\Local\Programs\Python\Python39
data!data!data!
data! data! data!
data data data
data!data!data</p>
<h3 id="📍전화번호-날짜">📍전화번호, 날짜</h3>
<p>print(&quot;010&quot;,&quot;1234&quot;,&quot;1235&quot;,sep=&quot;-&quot;)
print(&quot;2021&quot;,&quot;03&quot;,&quot;10&quot;,sep=&quot;/&quot;)</p>
<blockquote>
</blockquote>
<p>010-1234-1235
2021/03/10</p>
<h3 id="📍세미콜론의-사용--한줄에-두개이상의-코드를-작성할때-사용다음줄로-넘어감">📍세미콜론의 사용 : 한줄에 두개이상의 코드를 작성할때 사용(다음줄로 넘어감)</h3>
<p>print(&quot;1&quot;); print(&quot;2&quot;)</p>
<blockquote>
<p>1
2</p>
</blockquote>
<h1 id="📒데이터형">📒데이터형</h1>
<h2 id="📍숫자number">📍숫자(Number)</h2>
<ul>
<li>정수, 실수, 8진수, 16진수</li>
<li>사칙연산 (+ - * / % ** //)</li>
<li>x ** y : x^y 제곱연산</li>
<li>// : 나눗셈 후 몫을 반환</li>
</ul>
<p>print(2 ** 2)
print(&quot;// :&quot;,(7 // 2))</p>
<blockquote>
</blockquote>
<p>4
// : 3</p>
<h2 id="📍문자열string">📍문자열(String)</h2>
<ul>
<li>단어, 문자 이루어진 문자의 데이터 집합</li>
<li>&quot; &quot; 사용</li>
<li>&#39; &#39; 사용</li>
<li>&quot;&quot;&quot; &quot;&quot;&quot; 사용</li>
<li>&#39;&#39;&#39; &#39;&#39;&#39; 사용</li>
</ul>
<p>name=&quot;홍길동&quot;;
print(name)</p>
<p>tmp = &quot;안녕하세요&quot; <br>      &quot;저는 부산에 사는 홍길동 입니다&quot;
print(tmp)</p>
<p>tmi = &quot;&quot;&quot;안녕하세요
저는 부산에 사는
홍길동 입니다&quot;&quot;&quot;
print(tmi)</p>
<blockquote>
</blockquote>
<ul>
<li>홍길동</li>
<li>안녕하세요저는 부산에 사는 홍길동 입니다</li>
<li>안녕하세요
저는 부산에 사는
홍길동 입니다</li>
</ul>
<h3 id="📍문자열-연결--문자열--문자열">📍문자열 연결 : [문자열 + 문자열]</h3>
<ul>
<li>print(&quot;안녕&quot;+&quot;하세요&quot;)</li>
<li><blockquote>
<p>print(&quot;안녕&quot;+1) : (문자열+숫자)(x)</p>
</blockquote>
</li>
</ul>
<p>tmp1 = &quot;Hello&quot;
tmp2 = &quot;Itwill&quot;
print(tmp1 + tmp2)
print(tmp1,tmp2)
print(tmp1,100)</p>
<blockquote>
</blockquote>
<p>안녕하세요
HelloItwill
Hello Itwill
Hello 100</p>
<h3 id="📍문자열-곱하기">📍문자열 곱하기</h3>
<p>print(&quot;A&quot; * 5)
print(&quot;안녕&quot;*5)</p>
<blockquote>
</blockquote>
<p>AAAAA
안녕안녕안녕안녕안녕</p>
<h3 id="📍문자열-길이">📍문자열 길이</h3>
<p>print(len(&quot;helloitwill&quot;))</p>
<blockquote>
<p>11</p>
</blockquote>
<h3 id="📍문자열-데이터는-배열에-저장인덱싱">📍문자열 데이터는 배열에 저장(인덱싱)</h3>
<ul>
<li>|H|e| l| l|o|</li>
<li>0 1 2 3 4</li>
<li>0~ 증가 인덱스 : 문자 데이터를 왼쪽에서 오른쪽으로 읽기</li>
<li>-1~증가 인덱스 : 문자 데이터를 오른쪽에서 왼쪽으로 읽기</li>
</ul>
<p>str = &quot;Hello&quot;
print(str[0])
print(str[-1],str[-2],str[-3],str[-4],str[-5])
print(str[-0])</p>
<blockquote>
</blockquote>
<p>H
o l l e H
H</p>
<h3 id="📍문자열-슬라이싱--문자열-자르기">📍문자열 슬라이싱 : 문자열 자르기</h3>
<p>str = &quot;Life is too short, You need Python&quot;
 &quot;Life&quot; 출력
print(str[0]+str[1]+str[2]+str[3])
print(str[0],str[1],str[2],str[3])</p>
<blockquote>
</blockquote>
<p>Life
L i f e</p>
<h3 id="📍시작번호--끝번호-시작번호--x--끝번호">📍[시작번호 : 끝번호] 시작번호 &lt;= x &lt; 끝번호</h3>
<p>print(str[0:4]) : 0<del>4
print(str[8:11]) : 8</del>11</p>
<p>print(str[0:]) : 0<del>끝
print(str[8:]) : 8</del>끝
print(str[:5]) : 처음~5</p>
<blockquote>
</blockquote>
<p>Life
too
Life is too short, You need Python
too short, You need Python</p>
<p>print(str[:]) : 처음~끝</p>
<blockquote>
</blockquote>
<p>Life is too short, You need Python</p>
<h3 id="📍10번-인덱스-값-변경">📍10번 인덱스 값 변경</h3>
<p>문자열 데이터타입은 해당 요소의 값을 변경 x
str[10] = &quot;A&quot;  -&gt; (x)</p>
<p>print(str[:10]+&quot;A&quot;+str[11:])</p>
<blockquote>
</blockquote>
<p>Life is toA short, You need Python</p>
<h1 id="📒문자열-포매팅">📒문자열 포매팅</h1>
<ul>
<li>%s - 문자열(String)</li>
<li>%c - 문자 1개(Character)</li>
<li>%d - 정수(Integer)</li>
<li>%f - 부동소수(Floating-point)</li>
<li>%o - 8진수</li>
<li>%x - 16진수</li>
<li>%% - % 문자값</li>
</ul>
<h3 id="📍강수확률-50-출력-50-포매팅으로-출력">📍&quot;강수확률 50%&quot; 출력 (50% 포매팅으로 출력)</h3>
<p>print(&quot;강수확률 %d %%&quot; %50)
-&gt; %% 두개는 %를 출력해냄</p>
<blockquote>
</blockquote>
<p>강수확률 50 %</p>
<h3 id="📍포매팅-여백">📍포매팅 여백</h3>
<ul>
<li><p>글자를 왼쪽에 여백 생성후, 글자는 오른쪽에서 채우기
print(&quot; hi %10s &quot; % &quot;홍길동&quot;)</p>
<blockquote>
</blockquote>
<p>hi ............       홍길동 </p>
</li>
<li><p>글자를 왼쪽에 적고 나머지 공간을 여백으로 채우기(-)</p>
<p>print(&quot; hi %-10s &quot; % &quot;홍길동&quot;)</p>
<blockquote>
</blockquote>
<p>hi 홍길동 ..............       </p>
</li>
<li><p>tmp = &quot;hello %d&quot; % 10 =&gt;&gt;&gt;&gt; {숫자} 순차적으로 접근, {이름} 이름으로 접근</p>
</li>
</ul>
<p>tmp = &quot;hello {0}&quot;.format(100)
print(tmp)</p>
<blockquote>
</blockquote>
<p>hello 100</p>
<p>tmp = &quot;hello {0} {1}&quot;.format(100,300)
print(tmp)</p>
<blockquote>
</blockquote>
<p>hello 100 300</p>
<p>tmp = &quot;hello {0} {1} {name}&quot;.format(100,300,name=&quot;홍길동&quot;)
print(tmp)</p>
<blockquote>
</blockquote>
<p>hello 100 300 홍길동</p>
<h3 id="📍문자열의-길이">📍문자열의 길이</h3>
<p>*문자열 내장 함수
str = &quot;itwill&quot;</p>
<p>print(&quot;문자열 길이 : &quot;+len(str)) (x)
print(&quot;문자열 길이 : &quot;, len(str))
print(&quot;문자열 길이(특정문자개수) : &quot;,str.count(&#39;w&#39;))</p>
<blockquote>
</blockquote>
<p>문자열 길이 :  6
문자열 길이(특정문자개수) :  1</p>
<p>print(&quot;특정 문자의 위치 : &quot;,str.index(&#39;w&#39;))
print(&quot;특정 문자의 위치 : &quot;,str.index(&#39;i&#39;)) <strong>0(왼쪽에서부터 탐색)</strong>
print(&quot;특정 문자의 위치 : &quot;,str.rindex(&#39;i&#39;)) <strong>3(오른쪽에서부터 탐색)</strong></p>
<p>print(&quot;특정 문자의 위치 : &quot;,str.index(&#39;a&#39;)) <strong>없는데이터 =&gt; 에러발생</strong></p>
<p>print(&quot;특정 문자의 위치 : &quot;,str.find(&#39;w&#39;))
print(&quot;특정 문자의 위치 : &quot;,str.find(&#39;a&#39;)) <strong>해당요소가 없을 경우 -1</strong></p>
<blockquote>
</blockquote>
<p>특정 문자의 위치 :  2
특정 문자의 위치 :  0
특정 문자의 위치 :  3
특정 문자의 위치 :  2
특정 문자의 위치 :  -1</p>
<p>print(str.upper())
print(str)
print(str.lower())</p>
<blockquote>
</blockquote>
<p>ITWILL
itwill
itwill</p>
<p>str2 = &quot;   hello&quot;
print(str2)
print(str2.lstrip())
str2 = &quot;hello    &quot;
print(str2.rstrip())
str2 = &quot;   hello   &quot;
print(str2.strip())</p>
<blockquote>
</blockquote>
<p>,,,,hello
hello
hello
hello</p>
<p>str2=&quot; itwill busan class &quot;</p>
<p>print(str2.replace(&quot;busan&quot;,&quot;jeju&quot;))</p>
<p>print(str2.split()) <strong>공백</strong>
print(str2.split(&quot;,&quot;)) <strong>구분자</strong>
<strong>리스트타입으로 결과를 리턴</strong></p>
<blockquote>
</blockquote>
<p> itwill jeju class 
[&#39;itwill&#39;, &#39;busan&#39;, &#39;class&#39;]
[&#39; itwill busan class &#39;]</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Java - Test 1]]></title>
            <link>https://velog.io/@joy_all/Java-Test-1</link>
            <guid>https://velog.io/@joy_all/Java-Test-1</guid>
            <pubDate>Fri, 22 Jan 2021 04:04:47 GMT</pubDate>
            <description><![CDATA[<h1 id="📒java-test">📒Java-test</h1>
<h2 id="📌-문제-1">📌 문제 1</h2>
<h3 id="1100까지-합계">1~100까지 합계</h3>
<h4 id="👉결과">👉(결과)</h4>
<p><img src="https://images.velog.io/images/joy_all/post/7b4cc426-4c28-4d17-9345-278c71994baf/image.png" alt=""></p>
<h4 id="✍입력">✍(입력)</h4>
<pre><code class="language-java">public class Test1 {

    public static void main(String[] args) {
        int sum = 0;

        for(int i=1;i&lt;=100;i++){
            sum += i;
        }
        System.out.println(&quot;1~100까지의 합 : &quot;+sum);
    }

}</code></pre>
<h2 id="📌-문제-2">📌 문제 2</h2>
<h3 id="scanner-라이브러리를-이용한-사칙연산-프로그램">Scanner 라이브러리를 이용한 사칙연산 프로그램</h3>
<h4 id="👉결과-1">👉(결과)</h4>
<p><img src="https://images.velog.io/images/joy_all/post/7222b222-ca38-4adb-84b8-19cdb70d89d7/image.png" alt=""></p>
<h4 id="✍입력-1">✍(입력)</h4>
<pre><code class="language-java">import java.util.Scanner;

public class Test2 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int a;
        int b;
        String c;

        System.out.println(&quot;정수 사칙연산 프로그램에 필요한 연산자를 입력하시오&quot;);
        System.out.println(&quot;( +, -, *, / )  &gt;&gt;&quot;);
        c = scanner.next();
        System.out.println(&quot;연산할 정수를 입력하시오 &gt;&gt;&quot;);
        a = scanner.nextInt();
        System.out.println(&quot;연산할 정수를 입력하시오 &gt;&gt;&quot;);
        b = scanner.nextInt();

        if(c.equals(&quot;+&quot;)){
            System.out.println(a + &quot;+&quot;+ b +&quot;=&quot; + (a+b));        
        }else if(c.equals(&quot;-&quot;)){
            System.out.println(a + &quot;-&quot;+ b +&quot;=&quot; + (a-b));
        }else if(c.equals(&quot;*&quot;)){
            System.out.println(a + &quot;*&quot;+ b +&quot;=&quot; + (a*b));
        }else if(c.equals(&quot;/&quot;)){
            double rst = (double)a/(double)b;
            System.out.println(a + &quot;/&quot;+ b +&quot;=&quot; + rst);
        }else{
            System.out.println(&quot;잘못된 값을 입력했습니다.&quot;);
        }
        scanner.close();
        System.out.println(&quot;프로그램 종료&quot;);
    }</code></pre>
<h2 id="📌-문제-3">📌 문제 3</h2>
<h3 id="scanner-라이브러리를-이용한-정보확인분석-프로그램">Scanner 라이브러리를 이용한 정보확인&amp;분석 프로그램</h3>
<h5 id="아래-예제-화면과-같이-학생의-이름과-점수를-입력-된-학생수에-맞게-입력하고-입력된-학생의-이름과-점수를-보거나-분석할-수-있도록-작성">아래 예제 화면과 같이 학생의 이름과 점수를 입력 된 학생수에 맞게 입력하고 입력된 학생의 이름과 점수를 보거나 분석할 수 있도록 작성</h5>
<h4 id="👉결과-2">👉(결과)</h4>
<p><img src="https://images.velog.io/images/joy_all/post/1946ae3c-db4f-4370-b8be-6065895f3829/image.png" alt=""></p>
<h4 id="✍입력-2">✍(입력)</h4>
<pre><code class="language-java">import java.util.Scanner;

public class Test3 {

    public static void main(String[] args) {
        boolean run= true;
        Scanner sc = new Scanner(System.in);
        //String [] names = null; //new String[100];
        //int [] scores = null;

        String[][] students = null;
        int studentNum = 0;

        while (run) {

            System.out.println(&quot;--------------------------------------------------&quot;);
            System.out.println(&quot;1.학생수 | 2.학생정보입력| 3.학생이름과점수보기 | 4.분석 |5.종료&quot;);
            System.out.println(&quot;--------------------------------------------------&quot;);

            System.out.print(&quot;선택 &gt; &quot;);
            int menuNo = sc.nextInt();

            switch(menuNo) {
            case 1 : 
                System.out.print(&quot;학생수 &gt; &quot;);
                studentNum = sc.nextInt();
                //names = new String[studentNum];
                //scores = new int[studentNum];
                students = new String [studentNum][2];

                break;
            case 2 :                
                for(int i=0 ;i&lt;studentNum; i++) {    
                    sc.nextLine();
                    System.out.print(&quot;이름 &gt; &quot;);                    
                    students[i][0] = sc.nextLine();                    
                    System.out.print(&quot;점수 &gt; &quot;);
                    students[i][1] =sc.nextLine();    


                }
                break;
            case 3 : 
                for(int i=0 ;i&lt;studentNum; i++) {                    
                    System.out.println(&quot;이름 : &quot;+students[i][0]+&quot; , 점수 : &quot;+students[i][1]);                    
                }
                System.out.println();
                break;
            case 4 :
                int sum =0;
                int maxScore =-1;
                int maxIndx =0;

                for(int i= 0; i&lt; studentNum ; i++) {
                    sum+=Integer.parseInt(students[i][1]);

                    if(Integer.parseInt(students[i][1]) &gt; maxScore) { 
                        maxScore = Integer.parseInt(students[i][1]);
                        maxIndx = i; //최고점수 해당하는 인덱스 값
                    }
                }

                System.out.println(&quot; 최고값 : &quot;+ maxScore+&quot; 이름 :&quot;+students[maxIndx][0]);
                System.out.println(&quot; 평균값 : &quot;+ (double)sum/studentNum);
                break;
            case 5 : 
                run = false;

            }

        }


        System.out.println(&quot;프로그램 종료&quot;);

    }</code></pre>
<h2 id="📌-문제-4">📌 문제 4</h2>
<h3 id="프로그램이-실행-될-수-있는-book-클래스-파일을-설계">프로그램이 실행 될 수 있는 Book 클래스 파일을 설계</h3>
<h5 id="아래의-책관리-프로그램의-일부분이-실행될-수-있도록-새-파일-작성">아래의 책관리 프로그램의 일부분이 실행될 수 있도록 새 파일 작성</h5>
<h4 id="👉결과-3">👉(결과)</h4>
<p><img src="https://images.velog.io/images/joy_all/post/554ce344-4a59-468f-b2ff-d9b2dfae5eee/image.png" alt=""></p>
<pre><code class="language-java">import java.util.Scanner;

public class Test4 {

    static Book [] books = new Book[10];
    static Scanner sc = new Scanner(System.in);
    static int insertCnt =0;

    public static void main(String[] args) {

        boolean run = true;        

        while (run) {
            System.out.println(&quot;---------------------------------------&quot;);
            System.out.println(&quot;1. 도서 정보 입력| 2. 책 검색 | 3. 종료&quot;);
            System.out.println(&quot;---------------------------------------&quot;);
            System.out.print(&quot;메뉴 선택 &gt;&quot;);
            int menuNo = sc.nextInt();

            switch (menuNo) {
            case 1:
                insertBook();
                break;
            case 2 :
                searchingBook();
                break;
            case 3: 
                run = false;
                break;
            }

        }

        sc.close();
        System.out.println(&quot;프로그램 종료&quot;);

    }

    static void insertBook(){

        if (insertCnt &lt; books.length) {
            insertCnt++;
            sc.nextLine();//Scanner입력을 위해 넣은 의미 없는 코드
            System.out.print(&quot;도서명 입력 : &quot;);
            String title = sc.nextLine();
            System.out.print(&quot;저자 입력 : &quot;);
            String author = sc.nextLine();
            System.out.print(&quot;출판사 입력 : &quot;);
            String publish = sc.nextLine();
            System.out.print(&quot;가격 입력 : &quot;);
            int price = sc.nextInt();

            books[insertCnt-1] = new Book(title, author, publish, price);            
            System.out.println(&quot;입력됨 &quot;);

        }else { System.out.println(&quot;더 이상 입력할 수 없습니다. &quot;); }

    }

    static void searchingBook(){
        if(insertCnt &gt; 0){
            System.out.print(&quot;검색할 책 제목을 입력 :&quot;);
            sc.nextLine();//Scanner입력을 위해 넣은 의미 없는 코드
            String searchinTitle = sc.nextLine();
            int i;
            for(i=0; i&lt;insertCnt;i++){
                if(searchinTitle.equalsIgnoreCase(books[i].getTitle())){
                    System.out.println(&quot;저자 : &quot;+books[i].getAuthor()+&quot; 출판사 : &quot;+books[i].publish+&quot; 가격: &quot;+books[i].price );
                    break;
                }
            }
            if(i&gt;= insertCnt) System.out.println(&quot;검색 책이 없습니다&quot;);

        }

    }

}</code></pre>
<h4 id="✍입력-3">✍(입력)</h4>
<pre><code class="language-java">public class Book {

    String title;
    String author;
    String publish;
    int price;

    public Book(String title, String author, String publish, int price) {
        super();
        this.title = title;
        this.author = author;
        this.publish = publish;
        this.price = price;
    }

    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getAuthor() {
        return author;
    }
    public void setAuthor(String author) {
        this.author = author;
    }
    public String getPublish() {
        return publish;
    }
    public void setPublish(String publish) {
        this.publish = publish;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }

}</code></pre>
<h2 id="📌-문제-5">📌 문제 5</h2>
<h3 id="간단한-주사위-게임을-만들기">간단한 주사위 게임을 만들기</h3>
<h5 id="아래와-같이-동작하도록-작성">아래와 같이 동작하도록 작성</h5>
<h4 id="👉결과-4">👉(결과)</h4>
<p><img src="https://images.velog.io/images/joy_all/post/769c5112-40ee-4f9e-a69b-ba2a189535a2/image.png" alt=""></p>
<h4 id="✍입력-4">✍(입력)</h4>
<pre><code class="language-java">import java.util.Scanner;

public class Test5 {

    public static void main(String[] args) {
     System.out.println(&quot;게임 설명 . 게임 종료는 exit 입력&quot;);
     boolean run =true;
     Scanner sc = new Scanner(System.in);

     while(run) {
         System.out.println(&quot;주사위가 굴러값니다. Enter키를 누르면 주사위 값이 나옵니다.&quot;);
         sc.nextLine();
         int num1 = (int)(Math.random()*6)+1;
         System.out.println(&quot;첫번째 주사위 값 : &quot;+ num1);

         System.out.println(&quot;주사위가 굴러값니다. Enter키를 누르면 주사위 값이 나옵니다.&quot;);
         sc.nextLine();
         int num2 = (int)(Math.random()*6)+1;
         System.out.println(&quot;두번째 주사위 값 : &quot;+ num2);

         System.out.println(&quot;주사위가 굴러값니다. Enter키를 누르면 주사위 값이 나옵니다.&quot;);
         sc.nextLine();
         int num3 = (int)(Math.random()*6)+1;
         System.out.println(&quot;세번째 주사위 값 : &quot;+ num1);

         if(num1== num2 &amp;&amp; num2 == num3) {
             System.out.println(&quot;빙고 !!!!&quot;);
         }

         System.out.println(&quot;게임 종료를 원하시면 exit를 입력하시고, 계속하실 경우 Enter키를 눌러주세요&quot;);
         String result = sc.nextLine();

         if(result.equalsIgnoreCase(&quot;exit&quot;))  run =false;         

     }

     System.out.println(&quot;프로그램 종료&quot;);
    }

}</code></pre>
]]></description>
        </item>
    </channel>
</rss>