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 }}
Uh oh!
There was an error while loading.
Please reload this page
.
dev-gmmahs
/
python-example
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
python-example
/
1_variable_n_print.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
52 lines (38 loc) · 1.65 KB
master
Breadcrumbs
python-example
/
1_variable_n_print.py
Copy path
Top
File metadata and controls
Code
Blame
52 lines (38 loc) · 1.65 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
# 1. 변수 선언 및 사용
# name 변수에 "홍길동" 문자열 대입
name = "홍길동"
# age 변수에 정수 10 대입
age = 10
# height 변수에 150.24 실수 대입
height = 150.24
# family 변수에 리스트 저장
family = ["엄마", "아빠", "누나"]
# score 변수에 딕셔너리 저장
score = {
"국어": 98,
"수학": 100,
"영어": 82
}
# hands 변수에 튜플 저장
# 튜플은 값을 변경할 수 없습니다.
hands = (3, 7)
# ========== 출력하기 ========== #
# 쉼표로 구분하여 문자열, 변수 등을 출력할 수 있습니다
print("제 이름은", name, "이고, 나이는", age, "입니다.")
# 문자열의 format 메소드를 사용하여 간편하게 포맷이나 위치를 지정할 수 있습니다.
print("제 키는 {}cm 입니다.".format(height))
# end="" 는 print 후 어떤 글자를 출력할지 정할 수 있습니다.
# 기본값으로는 \n(개행) 문자입니다
print("그리고 저의 가족 구성원은 ", end="")
# 리스트나 튜플은 반복가능한 객체이므로 for문에서 사용할 수 있습니다.
for f in family:
print(f, end=" ")
# len() 함수는 해당 객체의 길이를 반환합니다
print("이고 총 {}명 입니다.".format(len(family)))
# 딕셔너리.keys() 메소드는 해당 딕셔너리의 키 리스트를 반환합니다.
print("저의 이번 시험 성적은,")
for k in score.keys():
print("{}점수: {}점".format(k, score[k]))
print("입니다.")
# 튜플이나 리스트는 인덱스를 통해 접근하여 사용할 수 있습니다.
print("마지막으로 저는 왼손과 오른손을 {}:{} 만큼 씁니다.".format(hands[0], hands[1]))
You can’t perform that action at this time.