1. Вопрос: Запишите на языке Python следующие условия: 1) y ≠ 0; 2) х не кратно 7; 3) -5 < х < 10; 4) х е [-1; 1]. 2. Вопрос: Отметьте условия, записанные на языке Python правильно. 1) а ≥ 0 2) х 0 or у < 0 3. Вопрос: Составьте программу на Python, выводящую True, если высказывание является истинным, и False в противном случае 4. Вопрос: Даны значения целочисленных переменных: а = 10, b = 20. Чему будет равно значение логической переменной rez 5. Вопрос: Напишите программу на Python, которая запрашивает три строковые величины — взаимосвязанные прилагательное 6. Вопрос: Напишите и отладьте программу на Python, которая вводит строку с клавиатуры и выводит на экран её длину. 7. Вопрос: Известны координаты вершин A, B, C треугольника. Напишите программу на Python, вычисляющую площадь этого треугольника. 8. Вопрос: Известны длины сторон треугольника a, b, c. Напишите программу Python, вычисляющую площадь этого треугольника. 9. Вопрос: По заданным координатам точек А и В вычислите длину отрезка АВ на Python Вопрос: Для заданного x вычислите у по формуле y = x^3 + 2.5x^2 – x + 1 помогите пожалуйста
Ответы
1( y != 0; 2) x % 7 != 0; 3) -5 < x < 10; 4) x in [-1, 1]
2( 1( a >= 0; 2) x >= 0 or y < 0
3(
x = 5
y = 0
if x != 0:
print(True)
else:
print(False)
4( Значення логічної змінної rez буде False,
оскільки a не дорівнює b.
5(
adjective1 = input("Enter an interrelated adjective: ")
adjective2 = input("Enter an interrelated adjective: ")
adjective3 = input("Enter an interrelated adjective: ")
6(
string = input("Enter a string: ")
print("The length of the string is", len(string))
7(
import math
ax = int(input("Enter the x coordinate of point A: "))
ay = int(input("Enter the y coordinate of point A: "))
bx = int(input("Enter the x coordinate of point B: "))
by = int(input("Enter the y coordinate of point B: "))
cx = int(input("Enter the x coordinate of point C: "))
cy = int(input("Enter the y coordinate of point C: "))
ab = math.sqrt((bx - ax)**2 + (by - ay)**2)
bc = math.sqrt((cx - bx)**2 + (cy - by)**2)
ac = math.sqrt((cx - ax)**2 + (cy - ay)**2)
s = (ab + bc + ac) / 2
area = math.sqrt(s * (s - ab) * (s - bc) * (s - ac))
print("The area of the triangle is", area)
8(
import math
a = int(input("Enter the length of side a: "))
b = int(input("Enter the length of side b: "))
c = int(input("Enter the length of side c: "))
s = (a + b + c) / 2
area = math.sqrt(s * (s - a) * (s - b) * (s - c))
print("The area of the triangle is", area)
9(
import math
ax = int(input("Enter the x coordinate of point A: "))
ay = int(input("Enter the y coordinate of point A: "))
bx = int(input("Enter the x coordinate of point B: "))
by = int(input("Enter the y coordinate of point B: "))
distance = math.sqrt((bx - ax)**2 + (by - ay)**2)
print("The length of segment AB is", distance)
10(
x = float(input("Enter a value for x: "))
y = x**3 + 2.5*x**2 - x + 1
print("The value of y is", y)