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

Upload New File

parent abc6a1e9
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.
>>> b=22/7
>>> b
3.142857142857143
>>> type(b)
<class 'float'>
>>> # 부동소수형의 사칙 연산
>>> a=1.23 +0.32
>>> a
1.55
>>> b= 3.0 -1.5
>>> b
1.5
>>> c= 2.1 *2.0
>>> c
4.2
>>> d=4.5//2.0
>>> d
2.0
>>> e=4.5%2.0
>>> e
0.5
>>> f= 4.5/2.0
>>> f
2.25
>>> #복소수
>>> a = 2+3j
>>> a
(2+3j)
>>> type(a)
<class 'complex'>
>>> a.real
2.0
>>> a.imag
3.0
>>> a.conjugate()
(2-3j)
>>> #math모듈 사용
>>> import math
>>> math.pi
3.141592653589793
>>> math.e
2.718281828459045
>>> trunc(1.6)
Traceback (most recent call last):
File "<pyshell#27>", line 1, in <module>
trunc(1.6)
NameError: name 'trunc' is not defined
>>> math.trunc(1.6)
1
>>> abs(-123)
123
>>> round(1.4)
1
>>> round(1.5)
2
>>> math.factorial(10)
3628800
>>> math.factorial(100)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
>>> #파이썬은 메모리 허용범위내에서 정수를 무한히 찍어낼수있다.
>>> 3**3
27
>>> math.pow(3,3)
27.0
>>> math.sqrt(81)
9.0
>>> math.log(4,2)
2.0
>>> math.log(81,3)
4.0
>>> math.log10(1000)
3.0
>>> math.log(math.e)
1.0
>>> #텍스트 다루기
>>> a='hello,world.'
>>> a
'hello,world.'
>>> b="안녕하세요"
>>> b
'안녕하세요'
>>> c='''hello
welcome
java '''
>>> c
'hello\nwelcome\njava '
>>> d=""" hello
welcome
python"""
>>> d
' hello\nwelcome\npython'
>>> type(d)
<class 'str'>
>>> e=a+b
>>> e
'hello,world.안녕하세요'
>>> a[0:2]
'he'
>>> 'hel'in a
True
>>> x in a
Traceback (most recent call last):
File "<pyshell#60>", line 1, in <module>
x in a
NameError: name 'x' is not defined
>>> 'x' in a
False
>>> len(a)
12
>>> len(b)
5
>>> #문자열 메소드
>>> a = 'hello'
>>> a.startwith('h')
Traceback (most recent call last):
File "<pyshell#66>", line 1, in <module>
a.startwith('h')
AttributeError: 'str' object has no attribute 'startwith'
>>> a.startswith('h')
True
>>> a.startswith('e')
False
>>> a.endswith('h')
False
>>> a.endswith('o')
True
>>> a.fine('hel')
Traceback (most recent call last):
File "<pyshell#71>", line 1, in <module>
a.fine('hel')
AttributeError: 'str' object has no attribute 'fine'
>>> a.find('hel')
0
>>> a.find('ll')
2
>>> a.fine('x')
Traceback (most recent call last):
File "<pyshell#74>", line 1, in <module>
a.fine('x')
AttributeError: 'str' object has no attribute 'fine'
>>> a.find('x')
-1
>>> a.count('l')
2
>>> a='apple,orange,kiwi'
>>> b=a.split(',')
>>> b
['apple', 'orange', 'kiwi']
>>> type(b)
<class 'list'>
>>> b[0]
'apple'
>>> b[1]
'orange'
>>> b[2]
'kiwi'
>>> a=input()
b=input()
>>> resule= a*b
Traceback (most recent call last):
File "<pyshell#85>", line 1, in <module>
resule= a*b
TypeError: can't multiply sequence by non-int of type 'list'
>>> #문자열을 숫자로 바꾸기
>>> int('1234567890')
1234567890
>>> float('123.4567')
123.4567
>>> complex('1+2j')
(1+2j)
>>> print("첫수를 입력하시오 : ")
첫수를 입력하시오 :
>>>
=========== RESTART: /Users/kimminsub/Documents/input_multiply.py ===========
첫번째 수를 입력하시오:
5
두번째 수를 입력하시오:
4
5 * 4 = 20
>>> type(math.pi)
Traceback (most recent call last):
File "<pyshell#91>", line 1, in <module>
type(math.pi)
NameError: name 'math' is not defined
>>> import math
>>> type(math.pi)
<class 'float'>
>>> str(math.pi)
'3.141592653589793'
>>> type(math.pi)
<class 'float'>
>>>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment