Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Лаб. 1 КП АлГем

.docx
Скачиваний:
5
Добавлен:
30.08.2024
Размер:
16.67 Кб
Скачать

2*3 #Упражнение 1

6

k=3+4 #Упражнение 1 print(k)

7

(k+1)*(k-1) #Упражнение 1

48

(x+1)*(x-1) #Упражнение 1

--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In [15], line 1 ----> 1 (x+1)*(x-1) NameError: name 'x' is not defined

h=(k+2)*3+\ 3+(k+7) print(h) #Упражнение 1

Cell In [10], line 1 h=(k+2)*3+\ #Упражнение 1 ^ SyntaxError: unexpected character after line continuation character

a=3 b=4 c=a*b print(c)

12

a=-1 #Упражнение 2 b=3 c=2 k=(a+2)*(b-1)+c**(2*b) print(k)

66

a=4.2 #Упражнение 3 b=2.1 print(a+b) print(a+b==6.3)

6.300000000000001 False

x=1234.56789 format(x, '0.2f')

'1234.57'

format(x, '>10.1f')

' 1234.6'

format(x, '0.1f')

'1234.6'

format(x, '<10.1f')

'1234.6 '

format(x, '^10.1f')

' 1234.6 '

format(x, ',')

'1,234.56789'

format(x,'0,.1f')

'1,234.6'

%whos

Variable Type Data/Info ----------------------------- a float 4.2 b float 2.1 c int 2 f int 6 h int 44 k int 66 x float 1234.56789

del(h)

%whos

Variable Type Data/Info ----------------------------- a float 4.2 b float 2.1 c int 2 f int 6 k int 66 x float 1234.56789

format(x,'e')

'1.234568e+03'

format(x,'0.2E')

'1.23E+03'

del(a) del(b) del(c) del(f) del(k) del(x)

%whos

Interactive namespace is empty.

x=1 y=2 z=3 t=4

%whos

Variable Type Data/Info ---------------------------- t int 4 x int 1 y int 2 z int 3

del(x)

%whos

Variable Type Data/Info ---------------------------- t int 4 y int 2 z int 3

x=1/3-1/7 #Упражнение 4 y=2**4+2**-4 z=(3+0.2)/(1-0.35) print(format(x, '>6.3f')) print(format(y, '0.3f')) print(format(z, '>6.3f'))

0.190 16.062 4.923

import math print(math.sin(1))

0.8414709848078965

del(x)

import math #Упражнение 6 print(math.e) from math import pi print(pi)

2.718281828459045 3.141592653589793

from math import log, e, sqrt, sin, cos x=log(e**3-2) y=sqrt(sin(1)**2+cos(1)**2) print(x) print(y) #Упражнение 7

2.8951125538319022 1.0