Скачиваний:
47
Добавлен:
18.07.2023
Размер:
763.6 Кб
Скачать

1. Python.

.

Python .

Python PEP8.

. # $%.

& %.

numpy $* %. + $ matplotlib.

1.Python.

Python * * 0 1

. 2 Python 3 ,

3. 5 1 * python, *3 1

* 1, * 3 1 *3 .

2 6 1 *7 *, 6 3 3 6,

6 75 75 6 {}

begin end. = Python 6 6 , 6 6

6*3, , 1 * . &, , python , 3

6 3 1 3, 1 *

numpy * 6 6, 0 6* * * 1

* jit-*. , python

6 3 %. 2 *

1 1 jitpython pypy. 2

6 6 6

pypy-stm.

2. " .

1 *, , 3 1 ,

10 *.

1 *3 1 PEP 8 - Python. https://pythonworld.ru/osnovy/pep-8-rukovodstvo-po-napisaniyu-koda-na-python.html#id2

= IDE 6 3 7 3 *7 * pep-8.

=, PyCharm.

N IDE — Spyder, Idle.

Q 1 6 7 1 .

R 6 * ( 3 6 6* % 7,

*). 2 * 1 (, {, [, *75 3 1 0

*:

foo = long_function_name(var_one, var_two, var_three, var_four)

6

foo = long_function_name( var_one, var_two, var_three, var_four

)

Z 1 *7 CapitalizedWords ( 6*,

CapWords, CamelCase). + 3: 1 * 66 *

, 6* 66 * — HTTPServerError.

Z $* % - lower_case_with_underscores ( 1 6*

3).

Z $* % 1 1 6*,

1 3 0 6 , 3 6 * 3 1 3 6 1 1.

$ UPPERCASE_WITH_UNDERSCORES ( 6*

3). MY_MEGA_CONSTANT.

3. $ python.

*7 6 *7 6 * * 1 1 * on-line

75 * * python.

&65 % * 1 Desktop *.

3 % 6* Debian Linux: sudo apt-get install python3

sudo apt-get install pip3

2 * windows 3 1 * 5: https://www.python.org/downloads/

2 MacOs % * * .

2 6 : Repl It.

https://repl.it/languages/python3

+ 1 3 * * 1 1 . 2 * * 6 6.

Google Colab -- , * 1 ( * ) Jupyter Notebook' , 3l 6 * 6* * 1 * Runtime -> Change runtime type -> GPU, 6* 1 * * GPU (NVidia Tesla K80) .

& 6* 1 1 -- 3 1 6 3 * , 3 * 6* "6" 12 3. = 1, , 1 *7 1 6*3 1 6 1, 3 12 3. q 1 * * 1 * 6* Linux-

6 GPU 3 3-4, 0 3 (* 1 6 1

- ).

Q : https://colab.research.google.com

s 1 1 1 python3 % *7 * Linux (Debian, Ubuntu, Mint). 6 6 1 * - .

4.' . ( ) * + ,-,

/- pyhon3.

& Repl It. # 1 * %.

t * 1 – Python Repl It.

v 6 * &Q 1 python - Google Colab Repl it.

t * 2 – python

# 6* * 1 .

Z$% 6 % .

# , int, float, bool, str

>>>type(int) <class 'type'>

>>>type(2+2) <class 'int'>

>>>str1 = "Hello"

>>>print(str1) Hello

>>>type(str1)

<class 'str'>

>>>d = (1+2j)

>>>type(d)

<class 'complex'>

>>> complex(2.0) (2+0j)

# python, *, , 1, 7

6y. z 6y 1 *, 1 7 0 6y, 6y 6 1 * , 6 3 6 6 5 *. =, CLR JVM (75 jit- , 75 6- ) 7

.

Python 3 6 7 1 *75

.

# Python 3 7 .

# 1 1 3 O, l.

= 3 1 _, ( , _x_value), 1

1 *7 * *. =, 73 from mod1 import *, 6* _x_value, , 3, 1 1

* mod1 __all__ (75 1 *6 3 6y *).

# repl it * 1. (Add file). = mod1.py.

t * 3 – $

+ * . _x_value = 10 y_value = 10

__all__=['_x_value','y_value']

# $ main.py . import numpy

from mod1 import *

x = numpy.array([i for i in range(20)]) print(x)

print(y_value) print(_x_value)

6* 1 * __all__ 1, 3 *3.

t * 4 – } * 1

3 1 * 3 73 Python,

class_, int_, len_, for_.

6* 1 * 1 mod1 6 __all__. import mod1

print(mod1._x_value)

6* 1 * 1 mod1 6. import mod1 as md

print(md._x_value)

t * Python.

#

>>>flag = True

>>>flag

True

>>>flag+True

2

>>>flag and False False

>>>flag+False

1

#

>>>x = 2

>>>x**10 1024

#! " "

>>>x = 15//2

>>>x

7

>>>x = 15/2

>>>x

7.5

## "$

>>>x = 15%2

>>>x

1

# #

>>>str=input("Input any value: ") Input any value: 45

>>>val=int(input("Input any value: ")) Input any value: 45

>>>str

'45'

>>> val 45

#% & ' ( % "$ * &$) # * & & % ,$

>>>print("%03d:%10s %04d \n" % (flag,str,val)) 001: 45 0045

>>> print("%s:%15s %04d" % (flag,str,val))

True:

45 0045

>>>c=41

>>>f=56.12

# 15 " 20 & # " # 2 $ 3 2 , "

>>>print("%c %15.3f %020.5e" % (c,f,f))

)

56.120 0000000005.61200e+01

>>>str = "Hello world"

>>>len(str)

11

} $

>>>s = "{}".format(str)

>>>s

'Hello world'

>>>s = "{0} {1} {2}".format(str,14.24,True)

>>>s

'Hello world 14.24 True'

>>> print("{1:10.2f} {2} {0}".format(str,14.24,True)) 14.24 True Hello world

print("{0:^15}\n".format("*"),"{0:^14}\n".format("***"),"{0:^14}".format("*****"))

*

***

*****

>>> print("{0:^15}\n{1:^15}\n{2:^15}".format("*","***","*****"))

*

***

*****

>>> print("{0:^15}\n{1:^15}\n{2:^15}".format("*","*"*3,"*"*5))

*

***

*****

# f- # Python 3.6+

join — *

split 6 0

>>> print("".join([f"{'*'*(i*2+1):^15}\n" for i in range(5)]))

*

***

*****

*******

*********

>>>x = 9

>>>print("".join([f"{'*'*(i*2+1):^{x*2-1}}\n" for i in range(x)]))

>>>treg = lambda x,y: "" if x==-1 else treg(x-1,y)+f"{'*'*(x*2+1):^{y}}\n" print(treg(7,7*2+1))

exec('treg = lambda x,y,c: "" if x==-1 else treg(x- 1,y,c)+f"{(c)*(x*2+1):^{y}}\\n"\nprint(treg(6,6*2+1,"x"))')

#Z 1 Y — 6 6 3

print((lambda a:lambda v:a(a,v))(lambda s,x:"" if x==0 else s(s,x-1)+f"{'*'*(2*x-1):^15}\n")(8))

0 .

https://colab.research.google.com/

+ * 1 Google.

t * 5 – Q % 6

Q 6 0. File->Python3 new notebook.

t * 6 – t *

2 * 1 3 * *.

t * *7 * $ .

t * 7 - $

q 3 $* %

t * 8 – $ 3 $* %

t * 3 * 1 % 1

numpy.

t * 9 – 3

1* 6 3

2 * 6

1 +

= *, 3 1 6

1 numpy, 517 * 1 %.

&% 1 numpy 6 1,

3 1 1 $* % numpy. t * $* %.

2 % 1 * 1 * time.

=, 3 ppend 6 % (

6 3 6*$ ).

+= 6y .

: