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
d45953ca
Commit
d45953ca
authored
6 years ago
by
KimMinSeob
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
91f0e791
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
숫자형.py
+110
-0
110 additions, 0 deletions
숫자형.py
with
110 additions
and
0 deletions
숫자형.py
0 → 100644
+
110
−
0
View file @
d45953ca
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
=
123
>>>
a
123
>>>
type
(
a
)
<
class
'
int
'
>
>>>
a
=
-
123
>>>
a
-
123
>>>
type
(
a
)
<
class
'
int
'
>
>>>
a
=
0
>>>
type
(
a
)
<
class
'
int
'
>
>>>
a
=
1.2
>>>
type
(
a
)
<
class
'
float
'
>
>>>
a
=-
3.5
>>>
type
(
a
)
<
class
'
float
'
>
>>>
a
=
0o177
>>>
type
(
a
)
<
class
'
int
'
>
>>>
a
127
>>>
a
=
128
>>>
bin
(
a
)
'
0b10000000
'
>>>
a
=
127
>>>
bin
(
a
)
'
0b1111111
'
>>>
b
=
0x8ff
>>>
type
(
b
)
<
class
'
int
'
>
>>>
b
2303
>>>
b
=
0xABC
>>>
b
2748
>>>
#제곱연산자 **
>>>
a
=
3
>>>
b
=
4
>>>
a
**
b
81
>>>
#나눗셈후 나머지를 반환하는 연산자 %
>>>
7
%
3
1
>>>
7
%
4
3
>>>
#나눗셈후 몫을 반환하는 연산자 //
>>>
7
//
3
2
>>>
7
//
4
1
>>>
-
7
//
4
-
2
>>>
#음수에다가 // 할때 나눗셈의 결과값보다 작은정수중 가장 큰 정수를 리턴하기때문에 위에서 -2가됨
>>>
#연습문제 1
>>>
#국어 80, 영어 75, 수학 55 평균구하기
>>>
a
=
80
>>>
b
=
75
>>>
c
=
55
>>>
a
+
b
+
c
/
3
173.33333333333334
>>>
#17을 3으로 나누었을때 몫을 구하시오
>>>
17
//
3
5
>>>
#17을 3으로 나누었을때 나머지를 구하시오
>>>
17
%
3
2
>>>
#주어진 자연수가 홀수인지 짝수인지 판별하기
>>>
a
=
input
(
int
())
0
>>>
a
=
input
()
5
>>>
a
'
5
'
>>>
a
=
input
()
6
>>>
if
(
a
%
2
==
1
):
print
(
"
홀수이다.
"
)
elif
(
a
%
2
==
0
):
print
(
"
짝수이다.
"
)
Traceback (most recent call last):
File
"
<pyshell#57>
"
, line 1, in <module>
if(a%2 == 1):
TypeError: not all arguments converted during string formatting
>>>
type
(
a
)
<
class
'
str
'
>
>>>
a
=
int
(
intput
())
Traceback
(
most
recent
call
last
):
File
"
<pyshell#59>
"
,
line
1
,
in
<
module
>
a
=
int
(
intput
())
NameError
:
name
'
intput
'
is
not
defined
>>>
a
=
int
(
input
())
50
>>>
if
(
a
%
2
==
1
):
print
(
"
홀수이다.
"
)
elif
(
a
%
2
==
0
):
print
(
"
짝수이다.
"
)
짝수이다.
>>>
#input함수는 들어오는 모든걸 string형태로 받는다. int형으로 받으려면 위와같이 해야
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