Дробь:
x = int(input("x = "))
y = int(input("y = "))
z = (x*x-y*y)/(x*x+y*y)
print(z)
Пример:
x = 5
y = 3
0.47058823529411764
Куб:
a = int(input("a = "))
v = a*a*a
s = 6*a*a
print("v =",v," s =",s)
Пример:
a = 5
v = 125 s = 150
1.
n = 10
a = []
a = input().split()
print(a)
a[4] = '123'
print(a)
Пример:
99 12 5+6 ru ABC @ n 000 m 10
['99', '12', '5+6', 'ru', 'ABC', '@', 'n', '000', 'm', '10']
['99', '12', '5+6', 'ru', '123', '@', 'n', '000', 'm', '10']
2.
from random import random
n = 10
a = []
for i in range(n):
b = int(random() * 50)
a.append(b)
print(a)
a[0] = a[7]
print(a)
Пример:
[10, 17, 25, 36, 42, 45, 39, 27, 1, 36, 31]
[27, 17, 25, 36, 42, 45, 39, 27, 1, 36, 31]
3.
from random import random
n = 10
a = []
for i in range(n):
b = float(random())
a.append(b)
for i in range(n): print('%.3f' % (a[i]),end=' ')
print()
a[1] = 2*a[1]
for i in range(n): print('%.3f' % (a[i]),end=' ')
Пример:
0.957 0.570 0.227 0.140 0.782 0.472 0.490 0.024 0.924 0.574
0.957 1.141 0.227 0.140 0.782 0.472 0.490 0.024 0.924 0.574