Skip to content
Snippets Groups Projects
Commit d45953ca authored by KimMinSeob's avatar KimMinSeob
Browse files

Upload New File

parent 91f0e791
No related branches found
No related tags found
No related merge requests found
Python 3.7.1 (v3.7.1:260ec2c36a, 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형으로 받으려면 위와같이 해야
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment