    Python
 


  ,       ?      ,            .

    Python -  ,        .     :            .

   :

-       .

-      .

-        .

-  :  , , ,    .

    ,   ,   ,   ,        .





 

    Python





 1.      


1.1.  

 -   ,        .   ,    .        .          .

 1.1.       Python:

x = 3

print(x)

    3  x.      x    .      :    ,  .

1.2.  

  -  ,   ,     .     .      :      .     :      .    ,  - .

 1.2.  x = 3     Python:  ,  ,  .  3 = x    :        .   x = 3  :  3    x.

1.3.  

Python     .   - ,    - ,      .   ,       .       ,         ,      .

 :   Python     ,    .         .

 1.3.  hello.py,  

print("")

       Python      ,    .            .

1.4.  

Python -   .    - ,      ,       .    ,   Python   .    .

 .    ,  ,  ,  . :       .

 .          . :     ,   .

-.  ,        . : ,     .

 .      . :        .

        .         ;       .

1.5.  

    .  I ( 12)      .  II ( 310)   : , , , ,  , , .  III ( 11)    .  IV ( 1215)  : ,  ,     .  A       .

 :     ,    .     .       .

1.6. :   

     .     .

 1.   .   - ,         .

 2.  

python --version

   .     .   ,     .

 3.   hello.py  

print("")

  

python hello.py

    .     .       .

           2.     2 ,          python.     3        .      2.



  .

         .

      .

    Python,    1.4.

  ,    1.3.

          .

 ,        .



    1.6.     2     3.         1.6.

  hello.py:     ,   .  .  .

    :   7  a,   2  b,   a  b.  .  . ,    ,  - ,  - .

 ,     (   1.2).  .    . ,     -   .

        ,    1.4.      ,   .




 2.    


2.1.    

 - ,      Python,       .      1.3;           .

 - ,                 .      .   - ,        .      : Windows, macOS, Linux.         ;     .

 2.1.       python.      (      1.6).     ,           .

2.2.  

     .  - ,      .    

python --version

    python    --version,  .  --version  .  -  ,   .  --version    python ,         .

 -  ,  3.12.4,    .      3.8  .      : , , .   . :   3.12.4    3,  - 12,  - 4.

 :    ,   Python 3      3.8.  ,   Python 2,  ,     .   ,          python.      2.4.

 2.2. 

Python 3.12.4

  . 

Python 2.7.18

  .    ,    2.4.

2.3.   

 Python    :   .  -     ,       .

  - ,         ,      ,    .   - .    

python

  .    -   >>>,     .   - ,      .

  - ,             .   - .    

python _

  _ -  ,  .      12;      :  -   ,    .

     .      .                  .

 2.3.  :

>>> 2 + 3

5

   2 + 3,      5.      .

 :  sum.py  

a = 2

b = 3

print(a + b)

  python sum.py.       5.         .

2.4.     

     ,       ,    2.2.

 1.  . :    python --version      ,      . :     ,      python. :       2.1    .   :      .

 2.   2. :    Python 2. :     ,     ;       . :   3.8      2.1.     2      2.5:      ,   python   .

      .        2.2.

2.5.     

        .  python       .         .            .

python3 --version

 python3   3   ,   ,      python.        ,   .

     2.5:     - python --version  python3 --version -  ,   Python 3      3.8. ,  ,     . ,  ,    ""  .

 2.4.  python --version  Python 2.7.18.  python3 --version  Python 3.12.4.    .       python3.       .

2.6.  

  - ,     .  -       .      12;      :        .

      ( 2.3)    .  sum.py,   ,   ,  python sum.py  . :         ,    .

 -   ,  ,     .     :  Windows   \,  macOS  Linux -  /.      : ,    ,     .      .

 2.5.   - /home/user.  sum.py    /home/user.  python sum.py,    ,     .  sum.py,    /home/user/documents,  python sum.py     .  python documents/sum.py     :   documents/sum.py      documents  .

2.7.    

,   ,   :

  python --version.     2.2    4.

       1  2.4.   1.

   2   python3 --version.     2.5   python3   .        2  2.4    3.

  hello.py  ,    1.6,   .

   python hello.py ,     3 ,  python3 hello.py.

      1.6.

 .   3    2         .   6     .



  .

  .

   ,   . ,         .

  .        .

   3.12.4       .

   .

    .     .

   .

 ,    python3    python.

   . ,        .



  13  2.7.     .    3 ,          .

  46  2.7.     5.          2.6: ,           .

       .   2 + 3.  .   print("").  .    :   exit()    .

  vers.py,        (     2.2      ).  .  .      . ,   ,      .

  sum.py  ,   .   python sum.py   .  .    :     ;    ,    .    . ,       ,    .




 3. ,   


3.1. 

 -  ,     .    : , ,     .      8;        .

 - ,     .   Python   :   .   -    ,  3, -7, 0.   -    ,      ,  3.5, -0.25, 2.0.  2.0   ,    2;     ,     3.2.

 -  ,   .    :  ('')   ("").    ;      . ,    ,       .   - ,     ;  ""  ''.

  - ,     :   .   True,  - False.         ( 6  7);           .

 3.1.  :

3

-7

3.5

""

True

    -  .   -  .   - .   -  .   ,    ,    : ,   -,      .

3.2.  

  -  ,   ,   .     .     Python .          .

 ,    :

  (int) -  

  (float) -  

  (str) - 

  (bool) -  

  -   str,   type()    .  -   ,       ;      9,  -   3.4.

  int  float    .       :  /    int    float.   //   .  +    str  ,    ;    int - .     ,     ,    .      ,    3.5.

 3.2.     3.1:

type(3)        -> int

type(-7)       -> int

type(3.5)      -> float

type("") -> str

type(True)     -> bool

   :     type()   .  type(3) -> int :   3  int.

3.3. 

 - ,   .    .  - ,    .   - =.     ,  - .

x = 3

   x   3.     x    3   ,  .

    .  1:         _.  2:      ,    .  3:      .   - ,            .       9;      :  if, for, while, def, import ; ,    ,   .

    .  x   X -   .      .

 3.3.  : x, temperature, sum_2, _count.  : 2sum (  1), for (  3).  Sum   sum :   .

3.4.     

     ,  . ,    , -   .   ,    ,  .   - NameError.         13;     :   ,  NameError,    .

 3.4.  :

x = 3

print(x)

y

    x   3.     3:  x    .      y,    .   ,  NameError.    .      ;        13.

3.5.  

  -  ,      ,    .       ,    .          .      :      ( 3.2)   .

  :           .   ,   ,   type(),    3.2.

 3.5.     :

x = 3

type(x)   -> int

x = ""

type(x)   -> str

x = True

type(x)   -> bool

    x    int.     x    str.     x    bool.   x    .         :  3   int  ,   x     .            .

3.6.   

        .      ,   .

 1.   ,     :

a = 1

b = 2

c = 3

 2.          ,  :

a, b, c = 1, 2, 3

       2 .          .   - ValueError;     13.

 2    :    2     1,     .     15    .

 3.6. 

a, b, c = 1, 2, 3

    1,    a, b, c. 

a, b = 1, 2, 3

         ValueError.

3.7.  

    . ,    ,        .    ,               .

: ,    3,     5      3.  3        ;        .

 3.7.

x = 3

x = 5

    x   3.     5    x  .  x        3.  3  :       3.          .



  .

    ,   .      .

   .

    3       Python.

   int  float,   3.2.  ,      .

  .

     .

   .    ,    .

     .

   .

     .  ,      .

    . ,    ,    .



     :  ,  ,    ,    ,  .        type().      :     .      3.2.

 ,   temperature   36.6.    temperature   .  .   temperature   "".      .  .   ,    temperature   ,   type().

 ,        2  3.6.        .   .    .          3.6.

 ,   _count   0.  ,   2sum   1.   .    . ,    3.3 .

    :  x    10,   x    20.    type()   .    . ,     10   ,      3.7.

              3.3.        .       .    .




 4.   


4.1. 

 -  ,     .   - ,     .       . ,   ,  Python .

  - ,    .      :     ,    ,    .        .

      ,    4.3.           :        .

 4.1.     :

3            -> 3

x            -> ,     x

2 + 3        -> 5

2 + 3 * 4    -> 14

(2 + 3) * 4  -> 20

  - ;    .   - ;    . ,     - ;       4.3.        .

4.2. 

 - ,       . ,  ,    .    ,     .          .

  :









+



2 + 3

5

-



5 - 2

3

*



2 * 3

6

/



7 / 2

3.5

//

 

7 // 2

3

%

  

7 % 2

1

**

  

2 ** 3

8

,   /,         ( 3.2).   //   .    **    ,  ;     4.3.

  -  ,   :









==



2 == 3

False

!=

 

2 != 3

True

<



2 < 3

True

>



2 > 3

False

<=

  

2 <= 3

True

>=

  

2 >= 3

False

 == -     =;  =     ( 3.3).         :     ,    .     ,    ;     15.

  -     :









and

,    

True and False

False

or

,      

True or False

True

not

,   

not True

False

 - ,     .   and, or  ;   not  .  and  or   .  not   .

 4.2.     :

(2 + 3) * 4 > 19 and not (7 % 2 == 0)

    *,   >  ==,   and  not.     4.3.   -  True.

4.3.  

 - ,      .            .          .        **:      .

     :

** -   ;

*, /, //, % - , ,  , ;

+, - - , ;

==, !=, <, >, <=, >= - ;

not -  ;

and -  "";

or -  "".

   .        .       .     :      ,  ,     ,          .

 4.3.  ,   :

2 + 3 * 4      -> 14

(2 + 3) * 4    -> 20

2 ** 3 ** 2    -> 512

 :     ,  ;  3 * 4,  2 + 12.  :     ;  2 + 3,  5 * 4.  :      ;  3 ** 2,  2 ** 9.     512,   64:        ,     (2 ** 3) ** 2.

4.4.   

      .     .      ;      8.

 1.  +     ,       .    .

 2.  *       ,      .

 3.     .      ;     ,    .      .

 4.4.

"" + ""      -> ""

"" * 3 -> ""

"" > ""         -> True

    1.     2.     3.       :  +    ,   -  .      ( 3.2).

4.5.  

  -        .    : int(), float(), str().  int()     .  float()     .  str()    .

        :  3    3.0.         :  3.9    3.    ;     .

       1  True  0  False.        1.0  0.0.        "True"  "False".

       :       .       ValueError.      13.

 4.5.

int(3.9)      -> 3

float(3)      -> 3.0

str(3)        -> "3"

int("7")      -> 7

int("7.5") -> ValueError

   :  "7.5"    ,  .   "7.5"     int()  ;  ,   ,   float()       .

4.6.   

   ,    :     - ,   .      15,          .

  print()     .  - ,     ( 9).       .   print()  ,    .

 4.6. 

print(2 + 3 * 4)

   .  1:   2 + 3 * 4    4.3;  -  14.  2:  print()   14.              .



  .

  .    ,    4.2.

   =  ==      .

   .         .

,             -  .

   .      .

   .     .

  .      .

     ,    4.3.  ,           .

      ,    4.4.

   .    .

       .  ,         .



    .    .     .     .

2 + 3 * 4

(2 + 3) * 4

2 ** 3 ** 2

7 // 2

7 % 2

7 / 2    ,      .

 ,     (   4.2),    False.    .  .  .

   ,      .     .   .   . ,    4.3    .

    :    1  4.4,    2,    3    (True  False).   .    .




  .


   .

   ,     (https://www.litres.ru/book/georgiy-dimitriadi/vvedenie-v-iazyk-programmirovaniia-python-75040039/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


