Anaconda3 > Anaconda Prompt

(base) C:\Users\user>conda update -n base conda
    :
(base) C:\Users\user>conda update --all
    :
(py39-tf-cpu) C:\Users\user>pip install tensorflow
    :
(py39-tf-cpu) C:\Users\user>pip install keras
    :

Anaconda Navigator

  • beautifulsoup4
  • imageio
  • matplotlib
  • opencv
  • scikit-image
  • scikit-learn
  • scipy
  • tqdm

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
How To Update All Python Packages  (0) 2021.10.13
Fibonacci series  (0) 2021.08.16
Array/List  (0) 2021.08.16
Number, String  (0) 2021.08.15
>>> # Fibonacci series:
>>> a, b = 0, 1
>>> while a < 10:
...     print(a, end=',')
...     a, b = b, a+b
...
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
How To Update All Python Packages  (0) 2021.10.13
Anaconda3  (0) 2021.08.16
Array/List  (0) 2021.08.16
Number, String  (0) 2021.08.15
values = [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]

Slicing

print(values[0])   # 10
print(values[-1])  # 19
print(values[-3:]) # [ 17, 18, 19 ] 
print(values[7:])  # [ 17, 18, 19 ]
print(values[:3])  # [ 10, 11, 12 ]
print(values[a:b]) # a <= LIST < b
>>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']

>>> letters[2:5] = ['C', 'D', 'E']   # replace
>>> letters
['a', 'b', 'C', 'D', 'E', 'f', 'g']

>>> letters[2:5] = []    # remove
>>> letters[:] = []      # clear

Operation

list1 = [ 1, 2, 3 ]
list2 = [ 4, 5, 6 ]
list3 = list1 + list2   # [ 1, 2, 3, 4, 5, 6 ]

list1.append(10)   # [ 1, 2, 3, 10 ]
print(len(list1))  # 4

Nested

중첩 가능, 새로운 리스트를 한 리스트의 요소에 포함 가능

>>> a = [ 'a', 'b', 'c' ]
>>> b = [ 1, 2, 3 ]
>>> x = [ a, n ]
>>> x
[['a', 'b', 'c'], [1, 2, 3]]
>>> x[0]
['a', 'b', 'c']
>>> x[0][1]
'b'

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
How To Update All Python Packages  (0) 2021.10.13
Anaconda3  (0) 2021.08.16
Fibonacci series  (0) 2021.08.16
Number, String  (0) 2021.08.15

Numbers

  • Division (/) always returns a float.
  • The equal sign (=) is used to assign a value to variable.
  • If a variable is not 'defined' (assigned a value), trying to use it will give you an error.
  • In interactive mode, the last printed expression is assigned to the variable _.
  • supports types of numbers, such as int, float, Decimal and Fraction.
  • also has built-in support for complex numbers, and uses the j or J suffix to indicate the imaginary part (e.g. 3+5j).
>>> 8 / 5   # division always returns a floating number
1.6

>>> 17 // 3  # floor division discards the fractional part
5

>>> 17 % 3   # the % operator returns the remainder of the division
2

>>> 5 ** 2   # 5 squared
25

>>> 2 ** 7   # 2 to the power of 7
128

Strings

  • can be enclosed in single quotes('…') or double quotes (“…”)
  • \ can be used to escape quotes:
  • String literals can span multiple lines.
    • “”“…”“” or '…'
    • it's possible to prevent including end of lines by adding a \ at the end of the line
  • Python strings cannot be changed – they are immutable.
>>> 3 * 'a' + 'bcd'
'aaabcd'
>>> 'Py' 'thon'
'Python'

>>> text = ('Put several strings within parentheses '
...         'to have them joined together.')
>>> text
'Put several strings within parentheses to have them joined together.'

>>> prefix = 'Py'
>>> prefix 'thon'  # can't concatenate a variable and a string literal
  File "<stdin>", line 1
    prefix 'thon'
                ^
SyntaxError: invalid syntax

>>> ('a' * 3) 'bcd' # SyntaxError

>>> prefix + 'thon'
'Python'

>>> word = 'python'
>>> word[0]
'p'
>>> word[5]
'o'
>>> word[-1]
'n'
>>> word[0:2]
'py'
>>> word[2:5]
'tho'
>>> word[:2] + word[2:]
'python'

>>> word[100] # IndexError
>>> word[4:100]
'on'
>>> word[100:]
''
>>> len(word)
6

 

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
How To Update All Python Packages  (0) 2021.10.13
Anaconda3  (0) 2021.08.16
Fibonacci series  (0) 2021.08.16
Array/List  (0) 2021.08.16

+ Recent posts