Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Hae-Dal
python
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
python
/
if_example.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
81 lines (63 loc) · 2.01 KB
master
Breadcrumbs
python
/
if_example.py
Copy path
Top
File metadata and controls
Code
Blame
81 lines (63 loc) · 2.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'''
if문이란?
- 문제를 주어진 조건에 맞게 처리할 때 사용하는 문법이다.
기본 구조
*들여쓰기를 주의할 것
if 조건문 :
실행할 문장1
실행할 문장2
....
elif 조건문 :
실행할 문장A
실행할 문장B
...
else :
실행할 문장
실행할 문장
조건문이란?
- 참과 거짓을 판단하는 문장
- 우리가 임의로 정할수도 있고, 입력값에 따라 변하게 만들수도 있다.
money = True
if money :
실행할 문장
위의 코드를 실행해 보면 money가 참이기 때문에 if문 내부의 실행할 문장이 실행된다.
비교연산자
< : 좌변이 우변보다 작다.
> : 좌변이 우변보다 크다.
== : 좌변과 우변이 같다.
!= : 좌변과 우변이 다르다.
>= : 좌변이 우변보다 크거나 같다.
<= : 좌변이 우변보다 작거나 같다.
x or y : x와 y중 하나만 참이어도 참이다.
x and y : x와 y 모두 참이어야 참이다.
not x : x가 거짓이면 참이다.(반대로 됨)
in 조건문 - x라는 요소가 우변의 자료구조 안에 있으면 참
x in 리스트
x in 튜플
x in 문자열
not in 조건문 - in 조건문의 반대
x not in 리스트
x not in 튜플
x not in 문자열
'''
def example() :
x, y = input("두 수를 입력해주세요 : ").split()
x = int(x)
y = int(y)
if x < y :
print(f"x가 y보다 작다")
elif x > y :
print(f"x가 y보다 크다")
elif x == y :
print(f"x와 y가 같다.")
if __name__ == "__main__" :
example()
'''
문제
- 위의 코드를 수정해서 사칙연산을 수행 할 수 있는 계산기를 만들어 보세요.
입력예시
>>> 연산을 수행할 두 수를 띄어쓰기로 입력하세요 : 1 2
>>> 연산자를 입력해주세요 : +
출력예시
>>> 답은 3입니다.
'''
You can’t perform that action at this time.