Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KimMinSeob
Python
Commits
1837eb26
Commit
1837eb26
authored
6 years ago
by
KimMinSeob
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
fc63d289
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Exercise for.py
+146
-0
146 additions, 0 deletions
Exercise for.py
with
146 additions
and
0 deletions
Exercise for.py
0 → 100644
+
146
−
0
View file @
1837eb26
Python
3.7
.
1
(
v3
.
7.1
:
260
ec2c36a
,
Oct
20
2018
,
03
:
13
:
28
)
[
Clang
6.0
(
clang
-
600.0
.
57
)]
on
darwin
Type
"
help
"
,
"
copyright
"
,
"
credits
"
or
"
license()
"
for
more
information
.
>>>
a
=
[(
1
,
2
),(
3
,
4
),(
5
,
6
)]
>>>
for
(
first
,
last
)
in
a
:
print
(
first
+
last
)
3
7
11
>>>
#다섯명의 시험점수에 대하여 60이 넘으면 합격이고 그렇지 않으면 불합격이다. 결과보여주기
>>>
score
=
[
90
,
25
,
67
,
45
,
80
]
>>>
number
=
0
>>>
for
i
in
score
:
number
=
number
+
1
if
i
>=
60
:
print
(
"
%d번 학생은 합격입니다.
"
%
number
)
else
:
print
(
"
%d번 학생은 불합격입니다.
"
%
number
)
1
번
학생은
합격입니다
.
2
번
학생은
불합격입니다
.
3
번
학생은
합격입니다
.
4
번
학생은
불합격입니다
.
5
번
학생은
합격입니다
.
>>>
#위 코드에 continue추가하기
>>>
for
i
in
score
:
number
=
number
+
1
if
<
60
:
continue
else
:
print
(
"
%d번 학생 축하합니다.
"
%
number
)
SyntaxError
:
invalid
syntax
>>>
>>>
for
i
in
score
:
number
=
number
+
1
if
i
<
60
:
continue
else
:
print
(
"
%d번 학생 축하합니다.
"
%
number
)
6
번
학생
축하합니다
.
8
번
학생
축하합니다
.
10
번
학생
축하합니다
.
>>>
number
=
0
>>>
for
i
in
score
:
number
=
number
+
1
if
i
<
60
:
continue
else
:
print
(
"
%d번 학생 축하합니다.
"
%
number
)
1
번
학생
축하합니다
.
3
번
학생
축하합니다
.
5
번
학생
축하합니다
.
>>>
#range함수
>>>
a
=
range
(
10
)
>>>
a
range
(
0
,
10
)
>>>
type
(
a
)
<
class
'
range
'
>
>>>
#range(10)은 0부터 10미만의 숫자를 포함하는 리스트를 만들어준다.
>>>
#1 ~ 10 plus
>>>
sum
=
0
>>>
for
i
in
range
(
1
,
11
):
sum
=
sum
+
i
>>>
print
(
sum
)
55
>>>
for
i
in
range
(
2
,
10
):
for
j
in
range
(
1
,
10
):
print
(
"
%d 곱하기 %d = i*j
"
%
i
%
j
)
print
(
""
)
Traceback (most recent call last):
File
"
<pyshell#38>
"
, line 3, in <module>
print(
"
%d 곱하기 %d = i*j
"
%i %j)
TypeError: not enough arguments for format string
>>>
for
i
in
range
(
2
,
10
):
for
j
in
range
(
1
,
10
):
print
(
i
"
곱하기
"
j
=
i
*
j
)
print
(
""
)
SyntaxError
:
invalid
syntax
>>>
>>>
for
i
in
range
(
2
,
10
):
for
j
in
range
(
1
,
10
):
print
(
i
*
j
,
end
=
""
)
print
(
""
)
24681012141618
369121518212427
4812162024283236
51015202530354045
61218243036424854
71421283542495663
81624324048566472
91827364554637281
>>>
for
i
in
range
(
2
,
10
):
for
j
in
range
(
1
,
10
):
print
(
i
*
j
,
end
=
""
)
print
(
""
)
24681012141618
369121518212427
4812162024283236
51015202530354045
61218243036424854
71421283542495663
81624324048566472
91827364554637281
>>>
for
i
in
range
(
2
,
10
):
for
j
in
range
(
1
,
10
):
print
(
i
*
j
""
,
end
=
""
)
print
(
""
)
SyntaxError
:
invalid
syntax
>>>
>>>
for
i
in
range
(
2
,
10
):
for
j
in
range
(
1
,
10
):
print
(
i
*
j
+
"
/
"
,
end
=
""
)
print
(
""
)
Traceback (most recent call last):
File
"
<pyshell#48>
"
, line 3, in <module>
print(i*j +
"
/
"
,end=
""
)
TypeError: unsupported operand type(s) for +:
'
int
'
and
'
str
'
>>>
#for in list
>>>
a
=
[
1
,
2
,
3
,
4
]
>>>
result
=
[
num
*
3
for
num
in
a
]
>>>
print
(
result
)
[
3
,
6
,
9
,
12
]
>>>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment