Raspberry Pi ( python )
-
Ch03. 파이썬 기초 (제어문)Raspberry Pi ( python ) 2023. 2. 24. 11:14
1 _ if 문 : 다른 프로그램과 기능적으로 큰 차이는 없다. if , else , elif 문 3개가 있다. 기본 형태 if 조건: 실행문 else: 실행문 if 조건: 실행문 elif 조건: 실행문 else: 실행문 예제) 2 _ for 문 : 특정 코드를 지정 횟수만큼 반복하는 문장 for 변수 in range( 시작 값 , 조건값(원하는 종료값+1) , 증감값 ): 실행문 예제) - for 문을 선언할 때 처리할 목록은 리스트, 튜플, 문자열이 가능하고 이 변수들의 첫 요소부터 마지막 요소까지 변수에 대입되어 반복이 됩니다. 예제) 다양하게 for 문을 활용해보자 - print( ) 내부에 end="" 는 기본적으로 적용되어있는 print() 문의 개행을 없에고 print문이 출력이 끝난 지점에..
-
라즈베리파이 : 파이썬 연습문제 (02/23)Raspberry Pi ( python ) 2023. 2. 23. 16:48
02/23 1) # 1) type() 함수를 이용하여 아래 변수에 바인딩된 값의 타입을 판별해보세요. a = "132" print(type(a)) # 2) 변수 s 와 t에는 각각 문자열이 바인딩 되어있습니다. s = "hello" t = "python" # 두 변수를 이용하여 아래와 같이 출력 해보세요. print(s+"! "+t) print(s+"!",t) # 두 실행문은 같은 결과가 나온다 ( , = space 바) # 3) 아래 코드의 실행 결과를 예상해보세요. a = "3" b = "4" print(a + b) print("Hi" * 3) # 4) 화면에 '-'를 80개 출력하세요. print("-"*80) # 5) 변수에 다음과 같은 문자열이 바인딩되어 있습니다. t1 = 'python' t2..
-
Ch03. 라즈베리 파이를 위한 파이썬 기초Raspberry Pi ( python ) 2023. 2. 23. 16:31
01 _ 파이썬 : 빅 데이터 등의 통계, 함수와 관련된 코드를 만들기 좋은 프로그램이다. java나 javascript 와는 중괄호 개념이 다르고, 들여쓰기 규칙을 사용한다. Tab 키 사용을 지양하도록 하자. 예시) if 문을 사용한다면. def factorial(x): if x = 0: 참에 대한 결과1 참에 대한 결과2 else: 거짓에 대한 결과1 거짓에 대한 결과2 주석 # 한 줄 주석 ''' 여러 줄 주석 ''' """ 여러 줄 주석 """ print('주석 예제입니다.'); 02 _ 파이썬 자료형 1. 숫자형 : 정수 및 실수를 표현하는 타입. 타입을 키워드로 구분하지 않는다 a = 123 print(type(a))#type 함수는 변수의 타입을 리턴 a = 100 * 100 print(a..