Calculate Third Angle
Take two angles of a triangle and compute the third angle.
IntermediatePhase 1 - Level 3: Math and Number LogicExample 9 of 10
calculate-third-angle.py
1# Take two angles2angle1 = float(input("Enter first angle: "))3angle2 = float(input("Enter second angle: "))45# Calculate third angle6third_angle = 180 - angle1 - angle278# Validate9if third_angle > 0 and angle1 > 0 and angle2 > 0:10 print(f"Third angle: {third_angle} degrees")11else:12 print("Invalid triangle angles")
Output
Enter first angle: 60 Enter second angle: 60 Third angle: 60.0 degrees Enter first angle: 90 Enter second angle: 45 Third angle: 45.0 degrees
What's going on
Sum of angles in triangle is 180 degrees.
Key Concepts:
Third angle = 180 - angle1 - angle2
Validate that all angles are positive
Check if valid triangle
🔗Related Content
- 📖
Phase 1 - Learn Concepts
Review Phase 1 concepts and explanations
- 📝
Phase 1 - Quiz
Test your Phase 1 understanding with quiz questions
- 💻
Phase 1 - All Practice Problems
Explore all practice problems for Phase 1
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum