Angles are often used in Computer Science especially when creating 2D or 3D user interfaces. Angle measurements are given in either radians or degrees. In this blog post we will use degrees. As the angle increase, the name of the angle changes as explained in the pictures and in the table below:
|Type of Angle||Description|
|Acute Angle||an angle that is less than 90°|
|Right Angle||an angle that is 90° exactly|
|Obtuse Angle||an angle that is greater than 90° but
less than 180°
|Straight Angle||an angle that is 180° exactly|
|Reflex Angle||an angle that is greater than 180°|
Write a Python script that will ask the user to enter an angle between 0° and 360°.
The program should find out and output the type of angle (Acute, Right, Obtuse, Straight or Reflex) using the table of values provided above.
Once your code is done, complete the following tests to check that your code is working as it should:
|Test #||Input Values||Expected Output||Actual Output|
|#1||Angle: 30||Acute angle|
|#2||Angle: 90||Right angle|
|#3||Angle: 105||Obtuse angle|
|#4||Angle: 180||Straight angle|
|#5||Angle: 210||Reflex angle|
|#6||Angle: 420||Please try again with an angle value between 0 and 360 degrees.|
Challenge #2: Quiz
Write a Python script that will generate a random angle between 0° and 360°. The program should ask the user to give the name of the angle. If the user gets it right they should score 1 point.
The program should repeat this process ten times and output a final score out of ten.
To complete these two challenges you will need to use some selection statements (IF,ELIF,ELSE statements) as well as some comparison operators and Boolean operators (AND, OR, NOT).
The main comparison operators are:
|==||is equal to||4==4|
|!=||is different from||4!=7|
|<||is lower than||3<5|
|>||is greater than||9>2|
|<=||is lower or equal to||3<=5
|>=||is greater or equal to||9>=2
Solution...The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area