0

import math problem đŸ€”

We know tan 45° = 1 But in python, 1. why tan 45° = 0.999....? 2. How can I fix it? Sample input: tan 45° Expected output: 1 Sample input: tan 225° Expected Output: 1

15th Sep 2021, 5:04 AM
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ - avatar
2 Answers
+ 2
#I found a solution: from math import * x = tan(radians(45)) if str(0.999999) in str(x): x = round(x) print (x)
15th Sep 2021, 6:15 AM
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ - avatar