-
이론 정리프로그래밍/Python 2021. 4. 17. 10:14728x90
1. Data Types of Python
a_string = "like this" #str a_number = 3 #int a_float = 3.12 #float a_boolean = False a_none = None #존재하지 않음
2. Lists in Python (Mutable Sequence Types)
days = ["Mon","Tue","Wed","Thur","Fri"]
docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range
3. Tuples and Dicts
days = ("Mon","Tue","Wed","Thur","Fri") nico = { "name": "Nico", "age": 29, "korean": Ture, "fav_food": ["Kimchi","Sashimi"] }
4. Creating a Your First Python Function
def say_hello(): print("hello")
5. Function Arguments
def plus(a, b): print(a + b) plus(2, 5)
6. Returns
def plus(a, b): return a + b result = plus(2, 4) print(result)
7. Keyworded Arguments
def plus(a, b): return a + b result = plus(b=2, a=4) print(result) def say_hello(name, age): return f"Hello {name} you are {age} years old" hello = say_hello(name="nico", age="12") print(hello)
8. Conditionals part One
def plus(a, b): if type(b) is int or type(b) is float: return a + b else: return None print(plus(12, 1.2))
9. if else and or
def age_check(age): print(f"your are {age}") if age < 18: print("you cant drink") elif age == 18: print("you age new to this!") elif age > 20 and age < 25: print("you are still kind of young") else: print("enjoy your drink") age_check(29)
10. for in
days = ("Mon", "Tue", "Wed", "Thu", "Fri") for day in days: print(day)
days = ("Mon", "Tue", "Wed", "Thu", "Fri") for day in days: if day is "Wed": break else: print(day)
11. Modules
import math #올림하는 함수 print(math.ceil(1.2))
from math import ceil, fsum print(ceil(1.2)) print(fsum([1, 2, 3, 4, 5, 6]))
'프로그래밍 > Python' 카테고리의 다른 글
05. 연습문제 (0) 2021.01.14 04. 연습문제 (0) 2021.01.12 03. 연습문제 (0) 2021.01.08 [Python] 거북이 그래픽 - 해리포터 죽음의 성물 그리기 (0) 2020.03.18 01. python 설치하기 (0) 2019.06.07