생활 코딩 - 파이썬
🙊

생활 코딩 - 파이썬

Created
Jan 26, 2024 10:37 AM
Last edited time
Last updated January 26, 2024
Tags
Language
Language
Python
URL

Intro::

생활 코딩의 파이썬 강의 정리 노트 입니다
 
💡
python3 사용
 
파이썬은 쉘을 사용해서 직접 사용할 수도 있고 파일로도 실행 가능하다.
>>> a=1 >>> b=1 >>> a+b 2 >>> a=1;b=1;a+b 2 >>> a=1;\ ... b=1;\ ... a+b 2
 
\ (백슬래쉬)를 통해서 입력을 보류할 수 있다.
대화형 작업은 휘발성이기 때문에 참고하자
 

List 자료형

nums = [1, 2, 3, 4]
 

Dictionary 자료형

person = {'name': 'egoing', 'address': 'seoul', 'interest': 'Web'}

if elif else

조건문의 형태는 다음 코드와 같다
 
if True : print(1) if False : print(2) print(3) input_id = input("id: ")# 입력을 받을 수 있다. if input_id == "egoing" : print("Welcome") elif input_id == "ego" : print("r u egoing?") else : print("who r u??") input_id = input("id: ") input_password = input("password: ") id = "egoing" password = "1234" if input_id == id: if input_password == password: print("welcome") else : print("wrong password") else : print("wrong id")
 

반복문

다음과 같은 형태로 사용된다.
 
nums = [1, 2, 3, 4] for num in nums: print(num) persons = [ ['egoing', 'Seoul', 'Web'], ['basta', 'Seoul', 'IOT'], ['blackdew', 'Tongyeong', 'ML'], ] for person in persons: print(person[0] + ", " + person[1] + ", " + person[2]) name, address, interest = ['egoing', 'Seoul', 'Web'] print(name, address, interest) for name, address, interest in persons: print(name+','+address+','+interest)
 
 
 
 
 
 

References::

Loading Comments...