From d45953cada3e8143bb6e3fa9731f778c8e2451fc Mon Sep 17 00:00:00 2001 From: KimMinSeob <msmk530@ajou.ac.kr> Date: Fri, 7 Dec 2018 18:30:23 +0900 Subject: [PATCH] Upload New File --- ...41\341\204\222\341\205\247\341\206\274.py" | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 "\341\204\211\341\205\256\341\206\272\341\204\214\341\205\241\341\204\222\341\205\247\341\206\274.py" diff --git "a/\341\204\211\341\205\256\341\206\272\341\204\214\341\205\241\341\204\222\341\205\247\341\206\274.py" "b/\341\204\211\341\205\256\341\206\272\341\204\214\341\205\241\341\204\222\341\205\247\341\206\274.py" new file mode 100644 index 0000000..fa41b66 --- /dev/null +++ "b/\341\204\211\341\205\256\341\206\272\341\204\214\341\205\241\341\204\222\341\205\247\341\206\274.py" @@ -0,0 +1,110 @@ +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형으로 받으려면 위와같이 해야 -- GitLab