1)Write Python code that asks the user for two angles of a triangle. Then, first determine if the triangle can
exist (make sure that the third angle can be found such that the sum of the three angles is 180°, with all
angles both given and computed conforming to the definition of a triangle). If the triangle can’t exist,
print a message explaining the fact, and quit. If it can exist, then the code should proceed to step 2.
2. Discover whether the triangle has any of the following properties: right, acute, obtuse, isosceles,
equilateral. Print out this information in a formatted way, such as this (but with correct yesses/no’s):
Right: no
Acute: yes
Obtuse: no
Isosceles: yes
Equilateral: yes
3. Implement your program so that at the end, the user is asked if they want to compute
properties for another triangle; if they indicate they want to do so, perform the calculation again. This
option should be available an unlimited number of times, after each successive triangle computation.
Your menu code should accept these inputs to make a choice: "Yes", "yes", "y", "Y","No", "no", "n", or
"N". (Hint: draw a flow chart and then write pseudocode before attempting this).

## Recommended Answers

You forgot your pseudocode and code. Do not forget to push CODE

If you are too lazy to read the rules of the forum and have waited until the very last minute, then there is little chance of a reply.

Threads merged.

Well Jose,
first how would you determine this matematically?
then show us that you've written the pseudo-code.

## All 14 Replies

You forgot your pseudocode and code. Do not forget to push CODE

I dont know how to start this program, can you help me please

How about you start with the userinput, that's not too hard now is it?

please hel me set up the structure i really dont know so like this:

def main():

a = input('enter first number ')
b = input('enter second number ')
c = raw_input("")

1)Write Python code that asks the user for two angles of a triangle. Then, first determine if the triangle can
exist (make sure that the third angle can be found such that the sum of the three angles is 180°, with all
angles both given and computed conforming to the definition of a triangle). If the triangle can’t exist,
print a message explaining the fact, and quit. If it can exist, then the code should proceed to step 2.
2. Discover whether the triangle has any of the following properties: right, acute, obtuse, isosceles,
equilateral. Print out this information in a formatted way, such as this (but with correct yesses/no’s):
Right: no
Acute: yes
Obtuse: no
Isosceles: yes
Equilateral: yes
3. Implement your program so that at the end, the user is asked if they want to compute
properties for another triangle; if they indicate they want to do so, perform the calculation again. This
option should be available an unlimited number of times, after each successive triangle computation.
Your menu code should accept these inputs to make a choice: "Yes", "yes", "y", "Y","No", "no", "n", or
"N". (Hint: draw a flow chart and then write pseudocode before attempting this).

commented: Fail. -4

If you are too lazy to read the rules of the forum and have waited until the very last minute, then there is little chance of a reply.

If you are too lazy to read the rules of the forum and have waited until the very last minute, then there is little chance of a reply.

can you help me start this program please

Threads merged.

Threads merged.

an you help me write this please

We equal your effort, teacher actually even almost gave the pseudocode.

``````calculate_triangle()
while want_continue():
calculate_triangle()``````

We equal your effort, teacher actually even almost gave the pseudocode.

``````calculate_triangle()
while want_continue():
calculate_triangle()``````

I know, but how do I use that to write the code? To calculate the angle i need to add the two angles and subtract by 180.

i tried doing this but it doesnt work:

``````def main():
print('Enter Sides of the angle')
a = input('enter first angle ')
b = input('enter second second angle ')
c = 180-(a+b)

if (ab > c) & (ac > b) & (bc > a):
if(a == b) & (a == c):
print 'equilateral'
elif (a == b) | (a == c) | (b == c):
print 'isosceles'
else:
print 'scalene'
else: print "Invalid"

main()``````

can you help me with the first part pleaseeeeee

We equal your effort, teacher actually even almost gave the pseudocode.

``````calculate_triangle()
while want_continue():
calculate_triangle()``````

can you plese help me pytony??

Help yourself by reading instructions carefully:
If the triangle can’t exist, print a message explaining the fact, and quit.

ac etc. are not defined. & is not in correct context, it is binary bitwise and.

Well Jose,
first how would you determine this matematically?
then show us that you've written the pseudo-code.

well my PyScripter a FREE Python Scripter program creates this when i say make NEW

``````#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      Cap User
#
# Created:     19/10/2011
# Copyright:   (c) Cap User 2011
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python

def main():
pass

if __name__ == '__main__':
main()``````

this is how i start any program i do

``````#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      user
#
# Created:     13/09/2011
# Copyright:   (c) user 2011
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python

#>> ERW #>>
from time import gmtime, strftime;

#?? ERW #??
### ERW ###
### ERW ###
### ERW ###
#?? ERW #??

def main():
pass

#?? ERW #??
### ERW ###
### ERW ###
### ERW ###
#?? ERW #??

print("#>> ERW #>>",strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()));

print(); ### ERW ###

if __name__ == '__main__':
main()

#?? ERW #??
### ERW ###
### ERW ###
### ERW ###
#?? ERW #??

print(); ### ERW ###

print("#<< ERW #<<",strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()));#<< ERW #<<
input("Press Enter to continue..."); #?? ERW #??``````

so there you should be able to start what you wish to do if you just add some things like

``````a = input("please enter if you wish to make a trangle? Y/N")
if a.upper() == "Y"
print("good")
else
print("bad")``````

sorry i was only looking at first page of this thread ....
as for second page it looks like you are making Pseudocode not Python code but have not defined you logic well

if (ab > c) & (ac > b) & (bc > a):

don't understand is ab is meant to mean a * b or a + b ... i would be more likely to test

``````if a <= 180 & b <= 180 & a >= 0 & b >= 0
c = a + b - 180
else
print ("bad input ... please re-enter valid angles ... have a nice day ...")``````

before i would test if for type of traingle

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.