Assignment 2b: Triangle

Write a program Triangle that meets the following specifications:

The program asks the user for an angle in degrees.

The program asks the user for another angle in degrees.

The program calculates the third angle of a triangle with the first two angles, and prints out that value for the user.

A good program:

Provides clear instructions to the user.

Provides clear feedback to the user.

You can make this program even better using one or more conditionals.  Some angles won’t make any sense, and won’t form an actual triangle.  In this case you could give the user feedback such as:

“Those two angles don’t make a triangle.”

Getting numbers from the user:

To get numbers from the user, you can either use the input() function, or you can use the cs50 library functions called get_string(), get_int(), and get_float().

When you use input() or get_string(), you get a string.  If you want to ask the user her name, use input(), or get_string().

There are two kinds of numbers python recognizes.  Integers and floats.

When you want an integer, use int(input(“…”)) or use get_int().  Integers are for things you can count.

Floats are numbers that can (but don’t have to) have a decimal part.  To get a float from the user, use float(input(“…”)) or use get_float().  If you’re ever in doubt about whether something should be an int or a float, just ask if the thing could be 5.5.  If yes, then use a float.