{"id":18963,"date":"2021-08-29T15:13:04","date_gmt":"2021-08-29T09:43:04","guid":{"rendered":"https:\/\/python-programs.com\/?p=18963"},"modified":"2021-11-22T18:37:10","modified_gmt":"2021-11-22T13:07:10","slug":"python-program-to-compute-the-perimeter-of-trapezoid","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-compute-the-perimeter-of-trapezoid\/","title":{"rendered":"Python Program to Compute the Perimeter of Trapezoid"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Compute 1\/N!<\/a> A trapezoid is a four-sided geometrical figure with two sides that are parallel to each other. the sides that are parallel to each other are referred to as the “base” The other sides are referred to as “legs” (which may or may not be equal).<\/p>\n Formula to calculate Perimeter of a Trapezoid<\/strong> :<\/b><\/p>\n Perimeter (P) = a+b+c+d<\/p>\n where a, b = Bases of Trapezoid<\/strong> <\/b><\/p>\n c, d = Side length of Trapezoid<\/strong><\/b><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to calculate the perimeter of the given Trapezoid:<\/strong><\/b><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation of the above given approach:<\/strong><\/p>\n Output:<\/strong><\/p>\n Explore more instances related to python concepts from\u00a0Python Programming Examples<\/a>\u00a0Guide and get promoted from beginner to professional programmer level in Python Programming Language.<\/p>\n In the previous article, we have discussed Python Program to Compute 1\/N! Trapezoid: A trapezoid is a four-sided geometrical figure with two sides that are parallel to each other. the sides that are parallel to each other are referred to as the “base” The other sides are referred to as “legs” (which may or may …<\/p>\n
\nTrapezoid:<\/strong><\/p>\nGiven a= 10\r\nGiven b= 20\r\nGiven c= 35\r\nGiven d= 45<\/pre>\n
The Trapezoid's perimeter with the given values of a,b,c,d { 10 20 35 45 } = 110<\/pre>\n
Given a= 43\r\nGiven b= 17\r\nGiven c= 25.5\r\nGiven d= 32<\/pre>\n
The Trapezoid's perimeter with the given values of a,b,c,d { 43 17 25.5 32 } = 117.5<\/pre>\n
Program to Compute the Perimeter of Trapezoid in Python<\/h2>\n
\n
Method #1: Using Mathematical Formula (Static Input)<\/h3>\n
\n
# Give the first base of the trapezoid as static input and store it in a variable.\r\ngvn_a = 10\r\n# Give another base of the trapezoid as static input and store it in another variable.\r\ngvn_b = 20\r\n# Give the first side length of the trapezoid as static input and store it in a variable.\r\ngvn_c = 35\r\n# Give another side length of the trapezoid as static input and store it in another variable.\r\ngvn_d = 45\r\n# Calculate the perimeter of the given trapezoid using the above given mathematicalformula.\r\n# Store it in another variable.\r\nTrapzod_perimetr = gvn_a+gvn_b+gvn_c+gvn_d\r\n# Print the Trapezoid's perimeter with the given values of bases and side lengths.\r\nprint(\r\n \"The Trapezoid's perimeter with the given values of a,b,c,d {\", gvn_a, gvn_b, gvn_c, gvn_d, \"} =\", Trapzod_perimetr)\r\n<\/pre>\n
The Trapezoid's perimeter with the given values of a,b,c,d { 10 20 35 45 } = 110<\/pre>\n
Method #2: Using Mathematical Formula (User Input)<\/h3>\n
\n
# Give the first base of the trapezoid as user input using the float(input()) function\r\n# and store it in a variable.\r\ngvn_a = float(input(\"Enter some random variable = \"))\r\n# Give another base of the trapezoid as user input using the float(input()) function\r\n# and store it in another variable.\r\ngvn_b = float(input(\"Enter some random variable = \"))\r\n# Give the first side length of the trapezoid as user input using the float(input())\r\n# function and store it in a variable.\r\ngvn_c = float(input(\"Enter some random variable = \"))\r\n# Give another side length of the trapezoid as user input using the float(input())\r\n# function and store it in another variable.\r\ngvn_d = float(input(\"Enter some random variable = \"))\r\n# Calculate the perimeter of the given trapezoid using the above given mathematicalformula.\r\n# Store it in another variable.\r\nTrapzod_perimetr = gvn_a+gvn_b+gvn_c+gvn_d\r\n# Print the Trapezoid's perimeter with the given values of bases and side lengths.\r\nprint(\r\n \"The Trapezoid's perimeter with the given values of a,b,c,d {\", gvn_a, gvn_b, gvn_c, gvn_d, \"} =\", Trapzod_perimetr)\r\n<\/pre>\n
Enter some random variable = 43\r\nEnter some random variable = 12.6\r\nEnter some random variable = 4.9\r\nEnter some random variable = 20\r\nThe Trapezoid's perimeter with the given values of a,b,c,d { 43.0 12.6 4.9 20.0 } = 80.5<\/pre>\n<\/div>\n
\n