기본 문법
- 변수(Variable)
- 데이터 타입(Data Type) : 숫자(int, float), 문자열(str), 배열(list, dict), 객체 등
- 파이썬은 동적 타입 언어로, 변수 선언 시 데이터 타입을 지정하지 않아도 된다.
name = "Monica" # 문자열(String)
age = 20 # 정수(Integer)
is_Student = True # 불리언(Boolean)
- 연산자(Operators)
- 산술 연산자: +, -, *, /, //, %, **
- 비교 연산자: ==, !=, <, >, <=, >=
- 논리 연산자 : and, or, not
print(True and False) # False
- 조건문(if문)
num = 10
if num > 0:
print("양수")
elif num < 0:
print("음수")
else:
print("0")
- 반복문(for문 / while문)
for i in range(1,4):
print(i)
count=0
while count < 3:
print(count)
count += 1
- 함수(Function)
- def, lambda
def greet(name):
return "Hello " + name + "!"
print(greet("Monica"))
Practice
더보기
player1 = 35
player2 = 50
print("🎮 숫자 대결 게임! 🎮")
print("플레이어1 : " + str(player1) + "점")
print("플레이어2 : " + str(player2) + "점")
if player1 > player2:
print("🏆 플레이어 1이 승리했습니다! 🎉")
elif player1 < player2:
print("🏆 플레이어 2가 승리했습니다! 🎉")
else:
print("🤝 무승부! 두 플레이어가 같은 점수입니다.")
728x90
반응형
'초격차 캠프 11기 > 베이스 캠프 미션' 카테고리의 다른 글
VS Code (0) | 2025.04.02 |
---|---|
JavaScript 기초 (0) | 2025.04.02 |
CSS 기초 (0) | 2025.04.02 |
HTML 기초 (0) | 2025.04.02 |
[칼럼 읽기] 아토믹 해빗과 그릿 (0) | 2025.04.02 |