Hướng dẫn python program to calculate area of triangle rectangle circle - chương trình python để tính diện tích hình tròn hình chữ nhật tam giác

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọc

    Example:

    Input: shape name = "Rectangle"
           length = 10
           breadth = 15
    Output: Area: 150
    
    Input: shape name = "Square"
           side = 10
    Output: Area: 100

    Approach:

    Bàn luận

    Chúng tôi sẽ thực hiện một chương trình Python để tính toán các khu vực của một số hình dạng toán học.

    Python3

    Trong chương trình này, chúng tôi sẽ yêu cầu người dùng nhập tên hình dạng. Nếu nó tồn tại trong chương trình của chúng tôi thì chúng tôi sẽ tiến hành tìm khu vực hình dạng đã nhập theo các công thức tương ứng của chúng. Nếu hình dạng đó không tồn tại thì chúng tôi sẽ in xin lỗi! Chúng ta không thể tìm thấy hình dạng này. thông báo trên màn hình.

    Dưới đây là việc thực hiện:

    def calculate_area(name):\

      name = name.lower()

      if name ==

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    3
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    4

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    6=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def223

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  0  1  2

      3  4

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5def5=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9calculate_area(name):\1def3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5calculate_area(name):\4=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    6calculate_area(name):\7 calculate_area(name):\8

        6 name == name 0

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    4

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  0=9  2

      3name.lower()2

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5name 3=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9name 9def3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5=2= name 3calculate_area(name):\7 =6

        6 name == name.lower()8

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    4

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  1=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9  7def3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    08  2

      3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    11

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5def5=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9if6def3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5if9=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    01 calculate_area(name):\7 def5calculate_area(name):\7

        6 name ==

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    17
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    4

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    20=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    26def3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    42  2

      3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    45

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    29=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    31

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    33=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    29calculate_area(name):\7
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    20calculate_area(name):\7
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    39

        6 name ==

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    51
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    4

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5def5=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    60def3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    79  2

      3

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    82

      

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    84
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    4

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    89
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    90

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5  1=
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    8
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def0
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    69def3

        0

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    9def00
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    90

    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    5
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    72= def5calculate_area(name):\7
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    05

      def10

    Output:

    if
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    92==
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    95
    Calculate Shape Area
    Enter the name of shape whose area you want to find: rectangle
    Enter rectangle's length: 10
    Enter rectangle's breadth: 15
    The area of rectangle is 150.
    4

    Làm thế nào để bạn lập trình khu vực của một tam giác trong Python?

    Chương trình Python để tìm khu vực của một tam giác..
    # Ba mặt của tam giác là A, B và C:.
    a = float (input ('nhập mặt đầu tiên:')).
    b = float (đầu vào ('nhập phía thứ hai:')).
    c = float (đầu vào ('nhập phía thứ ba:')).
    # Tính toán semi-perimet ..
    s = (a + b + c) / 2 ..
    # Tính diện tích ..
    diện tích = (s*(s-a)*(s-b)*(s-c)) ** 0,5 ..

    Làm thế nào để bạn tìm thấy khu vực của một vòng tròn trong Python?

    Phương pháp tìm diện tích của vòng tròn đã cho bằng Python..
    Nhập toán như M ..
    Bán kính = Float (đầu vào ("Vui lòng nhập bán kính của vòng tròn đã cho:")).
    Area_of_the_circle = m.pi * Bán kính * Bán kính ..
    in ("Khu vực của vòng tròn đã cho là:", area_of_the_circle).

    Làm thế nào để bạn giải quyết khu vực trong Python?

    Chương trình Python để tìm một khu vực của một hình chữ nhật..
    Đầu tiên, chúng tôi sẽ lấy đầu vào từ người dùng về chiều dài và chiều rộng bằng cách sử dụng hàm input () ..
    Bây giờ, chúng tôi sẽ tính diện tích của một hình chữ nhật bằng cách sử dụng vùng công thức = l * b ..
    Cuối cùng, in khu vực của một hình chữ nhật để xem đầu ra ..