basic | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

basic

can we compare fractional and integer by using > symbol?

15th Dec 2019, 7:11 AM
arani pavan
3 Answers
+ 5
Do you mean like this? x = 1/3 y = 1 print(x > y) print(y > x)
15th Dec 2019, 7:40 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
if this is what you mean, please keep in mind that a computer can’t do fractions. 1/3 is not a proper fraction for a computer only a float to a certain amount of numbers behind the decimal point. so it is not 1/3 but instead 0,3333333333333333333333333333 etc this has implications for your results and also when using round, ceil, floor etc
15th Dec 2019, 8:15 AM
Brave Tea
Brave Tea - avatar
+ 2
Brave Tea Good point, glad you raised it. 👍
15th Dec 2019, 8:18 AM
Rik Wittkopp
Rik Wittkopp - avatar