Информатика, вопрос задал vikkasx0 , 1 год назад

Допоможіть будь ласка
в Puthon
•Створити програму для визначення площі ромба за довжиною сторони і висоти​.
•Створити програму для визначення площі трикутника за трьома сторонам і радіусом описаного кола
•Створити програму для визначення вартості покупки (ціна і кількість п’яти предметів, визначити і вивести на екран вартість окремо предметів й загальну вартість покупки)​

Ответы на вопрос

Ответил asilvejstruk
1

# Програма для визначення площі ромба

def calculate_area_of_rhombus(side, height):

   area = side * height

   return area

 

# Введення даних

side = float(input("Введіть довжину сторони: "))

height = float(input("Введіть висоту: "))

 

# Отримання результату

result = calculate_area_of_rhombus(side, height)

 

# Виведення результату

print("Площа ромба:", result)

# Програма для визначення площі трикутника

def calculate_area_of_triangle(a, b, c):  

   # Calculate the semi-perimeter  

   s = (a + b + c) / 2

   # Calculate the area  

   area = (s*(s-a)*(s-b)*(s-c)) ** 0.5

   return area  

# Driver Code  

a = float(input("Enter the value of a : "))  

b = float(input("Enter the value of b : "))  

c = float(input("Enter the value of c : "))  

# Calculate the area of triangle  

result = calculate_area_of_triangle(a, b, c)  

print("The Area of Triangle is : %.2f" %result)    

    # Program to calculate cost of purchase.    

items=[]    

cost=[]    

n=int(input('How many items you want to buy? '))    

for i in range (n):    

   items.append(input('Enter item name '))    

   cost.append(float(input('Enter cost of item ')))    

total=0    

for i in range (n):

   total+=cost[i]

   print('Total cost of ',items[i],'is',cost[i])    

   print('Total cost of purchase is',total)


vikkasx0: Дякую!!!!
Новые вопросы