Day 3 of #30DaysOfCode : Area and Circumference Calculation

Day 3 of #30DaysOfCode : Area and Circumference Calculation

Question:

In the GitHub repository, Infinity_AI(Infinite Learn and Grow)/30-days-code inside the Day-3 folder create a name.py file as defined in the readme.md file.

  • Write a script that prompts the user to enter the base and height of the triangle and calculate the area of this triangle(area = 0.5 x b x h).

  • Get the radius of a circle using the prompt. Calculate the area (area = pi x r x r) and circumference ( c = 2 x pi x r) where pi = 3.14.

Solution:

First of all, we need two values Base and Height from the user. so we can write the code which is taking input of Base and Height from the user. In this solution, we are taking input as a float because the values of base and height might be floating values.

Now we are calculating the area of the triangle using the formula which is already given in the question And assign the result in a variable and at the end print the value of the area using print().

Now, we need to get the value of the radius from the user to calculate the area and circumference of a circle.

Now to calculate the area and circumference formula is already given in the question.

Thank you :-)