상세 컨텐츠

본문 제목

2023.04.18

Python

by 연을 2023. 4. 18. 17:25

본문

728x90

[phthon]

https://www.python.org/ : 3.11.3 download 꼭 밑에 있는 add? 였나 체크

cmd 에서 python 경로 확인해주기(밑의 사진처럼 경로가 떠야 제대로 설치된거다.)

IDE(Integrated Development Environment) : 통합 개발 환경 공통된 개발자 툴을 하나의 그래픽 사용자 인터페이스(GUI) 로 결합하는 애플리케이션을 구축하기 위한 소프트웨어 ex) eclipse, VSC, Pycharm

pycharm download : https://www.jetbrains.com/ko-kr/pycharm/download/#section=windows community용 다운로드

 

javascript 타입을 지정하지 않아도 된다. let i=0;
i=0;
var i=0;
String str1 = "Hello World";
String str1 = 'Hello World';
java int float String
타입을 지정해 줘야 한다
java의 String은 선언할 경우 ""만을 써야한다.
int i=0;
String str1 = "Hello World";
String str1 = 'Hello World';⇒얘는 안됨
python 타입을 지정해 주지 않아도 알아서 바뀜
';'을 쓰지 않음.
type(i) : i의 type을 알고 싶을 경우 사용하는 함수
i="Hello"
i=0
str1 = "Hello World"
str1 = 'Hello World'

print() == System.out.println() == document.write()

System.out.println() == document.write()는 ()안에 하나의 문자열만 선언가능.

input() == new Scanner() == prompt()

python은 몫을 구하는 연산자가 있다. : //

ex) i="hello"
j=3
i+j
 
i+str(j)

[if문]

i=10
j=15
if i<j:
    print(str(i)+'가 작다')
print('종료')
i=10
j=15
if i>j:
    print(str(i)+'가 작다')
else:
    print(str(i)+'가 작거나 같다')
print('종료')
i=input('i값을 넣으시오 : ')
j=input('j값을 넣으시오 : ')
i=int(i)
j=int(j)
if i>j:
    print(str(j)+'가 작다')
else:
    print(str(i)+'가 작거나 같다')
print('종료')
i=input('i값을 넣으시오 : ')
j=input('j값을 넣으시오 : ')
i=int(i)
j=int(j)
if int(i)>int(j):
    pass or None
else:
    pass or None도 가능
print('종료')
i=input('i값을 넣으시오 : ')
j=input('j값을 넣으시오 : ')
if int(i)>int(j):
    print(j+'가 작다')
elif int(i)<int(j):
    print(i+'가(이) 크다')
else:
    print(i+'와(과)'+j+'가 같다')
print('종료')

[점수분류하기]

i=input('점수를 입력하세요 : ')
if int(i)>=90:
    print('A')
elif int(i)>=80:
    print('B')
elif int(i)>=70:
    print('C')
elif int(i)>=60:
    print('D')
else:
    print('F')
python elif 80<=jumsu<90 : &&표시를 쓰지 않고 이렇게 표현 가능
그 외 언어 else if(80<=jumsu && jumsu<90)
python res = '참' if a>2 else '거짓' : 삼항연산자를 쓰지 않아도 된다.
그 외 언어  res =(a>3) ? '참': '거짓'
그 외 언어 python
if 비교문 :
    실행문1
    실행문2
실행문3
if 비교문 :
    실행문1
else :
    실행문2
실행문3
if 비교문1 :
    실행문1
elif 비교문2 : 
    실행문2
else :
    실행문3
실행문4

[end 함수]

print(a) == System.out.println(a); print는 줄바꿈을 포함한다.
print(a,end=' ') == System.out.print(a); end는 줄바꿈을 없앤다.

[while문]

python
while 조건문 :
    실행문1
    ....
    실행문N
실행문X

[1부터 100까지의 합]

i=1
sum=0
while i<=100:
    sum +=i
    i += 1
print(sum)
print('종료')

[2단부터 9단 구구단]

i=2
j=1
while i<=9:
    while j<=9:
        print(str(i)+"x"+str(j)+"="+str(i * j))
        j +=1
    i+=1
    print()
    j=1

[100이하의 3의 배수]

i=1
while i<=100:
    if i % 3==0:
        print(i)
    i+=1

 

728x90

'Python' 카테고리의 다른 글

2024.04.25  (1) 2023.04.25
2023.04.24  (1) 2023.04.24
2023.04.21  (0) 2023.04.21
2023.04.20  (1) 2023.04.20
2023.04.19  (0) 2023.04.19

관련글 더보기