create account

SIMPLE PYTHON CLASS EXAMPLE TO CALUCLATE THE AREA OF TRIANGLE by leoumesh

View this thread on: hive.blogpeakd.comecency.com
· @leoumesh ·
$2.81
SIMPLE PYTHON CLASS EXAMPLE TO CALUCLATE THE AREA OF TRIANGLE
```
class Triangle:
    pass

triangle1=Triangle()

triangle1.height=10
triangle1.base=12

print(1/2*triangle1.height*triangle1.base)
```

The output was as follows when I run this program:


![Screenshot_2.png](https://cdn.steemitimages.com/DQmPzv6LJ2Ue5dAjU5uCaJe9dk981zNdfuPzfnUacTkDezj/Screenshot_2.png)

I declare a class named Triangle. Then I created an instance of that class which is triangle1. triangle1 is also the object of the class Triangle. Then I set the attribute of that object triangl1 which as height and base and then finally printing the value by using the formula of area of triangle.

You can run this program online [here](https://www.onlinegdb.com/online_python_compiler), just copy paste the code.
👍  , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorleoumesh
permlinksimple-python-class-example-to-caluclate-the-area-of-triangle
categorycoding
json_metadata{"tags":["coding","programming","python","study","language"],"image":["https://cdn.steemitimages.com/DQmPzv6LJ2Ue5dAjU5uCaJe9dk981zNdfuPzfnUacTkDezj/Screenshot_2.png"],"links":["https://www.onlinegdb.com/online_python_compiler"],"app":"steemit/0.2","format":"markdown"}
created2020-03-10 14:09:45
last_update2020-03-10 14:09:45
depth0
children0
last_payout2020-03-17 14:09:45
cashout_time1969-12-31 23:59:59
total_payout_value1.407 HBD
curator_payout_value1.400 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length724
author_reputation212,340,493,251,438
root_title"SIMPLE PYTHON CLASS EXAMPLE TO CALUCLATE THE AREA OF TRIANGLE"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,235,388
net_rshares11,867,608,855,700
author_curate_reward""
vote details (23)