N butun son berilganu ning darajasi ekanligini aniqlang


except: with open("output.txt", "w") as output_file


Download 134.94 Kb.
bet8/10
Sana22.06.2023
Hajmi134.94 Kb.
#1647477
1   2   3   4   5   6   7   8   9   10
Bog'liq
dasturlash shpargalka

except:
with open("output.txt", "w") as output_file:
output_file.write("Berilgan nuqtalardan kesma hosil qilinmadi")


33) “input.txt” faylida x1,y1 x2,y2 x3,y3 nuqtalarning
koordinatalari berilgan. Berilgan nuqtalardan uchburchak
yasab bo’lsa, burchagiga ko’ra qanday uchburchakligini
output.txt” fayliga yozsin
import math
with open("input.txt", "r") as file:
x1, y1, x2, y2, x3, y3 = map(int, file.readline().split())
a = math.sqrt((x2-x1)**2 + (y2-y1)**2)
b = math.sqrt((x3-x2)**2 + (y3-y2)**2)
c = math.sqrt((x1-x3)**2 + (y1-y3)**2)
alpha = math.degrees(math.acos((b2 + c2 - a**2) / (2 * b * c)))
beta = math.degrees(math.acos((a2 + c2 - b**2) / (2 * a * c)))
gamma = math.degrees(math.acos((a2 + b2 - c**2) / (2 * a * b)))
if alpha == 90 or beta == 90 or gamma == 90:
turi = "togri"
elif alpha > 90 or beta > 90 or gamma > 90:
turi = "otkir"
else:
turi= "otmas "
with open("output.txt", "w") as file:
file.write(turi)
34)”input.txt” faylida x1,y1 x2,y2 x3,y3 nuqtalarning
koordinatalari berilgan. Berilgan nuqtalardan uchburchak
yasab bo’lsa, tomoniga ko’ra qanday uchburchakligini
output.txt” fayliga yozsin
with open("input.txt", "r") as f:
x1, y1, x2, y2, x3, y3 = map(int, f.readline().split())
a = ((x2 - x1)2 + (y2 - y1)2)**0.5
b = ((x3 - x2)2 + (y3 - y2)2)**0.5
c = ((x1 - x3)2 + (y1 - y3)2)**0.5
if a == b == c:
turi = "Equilateral"
elif a == b or b == c or c == a:
turi= "Isosceles"
else:
turi = "Scalene"
with open("output.txt", "w") as f:
f.write(turi)
37)“input.txt” fayliga tasodifiy ravishda 50 ta [10, 1000]
orasidagi sonlarni yozing va shu sonlarni o’qib oling hamda

Download 134.94 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   10




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling