From 09cf635a334b811e2501892826ae8b76e60ce4c8 Mon Sep 17 00:00:00 2001 From: Abhilash Date: Mon, 14 Apr 2025 19:57:44 +0530 Subject: [PATCH] added degree to direction logic --- compass_code.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 compass_code.py diff --git a/compass_code.py b/compass_code.py new file mode 100644 index 00000000000..ec0ac377ba6 --- /dev/null +++ b/compass_code.py @@ -0,0 +1,8 @@ +def degree_to_direction(deg): + directions = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"] + + deg = deg% 360 + deg = int(deg//45) + print(directions[deg]) + +degree_to_direction(45) \ No newline at end of file