Re: [Tutor] Difference between rounding off and typecasting to int

2016-01-02 Thread Alan Gauld
On 02/01/16 14:33, Ratheesh kumar wrote: > But I can't get to understand what round() did int() cant't do With this kind of question its best to ask the interpreter: >>> int(12.1) 12 >>> int(12.9) 12 >>> round(12.1) 12 >>> round(12.9) 13 >>> Does that make it clearer? -- Alan G Author of the

[Tutor] Difference between rounding off and typecasting to int

2016-01-02 Thread Ratheesh kumar
Hii everyone, Today i was just solving a problem in hacker-rank. A simple one to calculate the tip and tax for the meal. The resultant answer should be rounded off. I first wrote the code as below: m=float(input()) x=int(input()) t=int(input()) tip=(m*x)/100 tax=(m*t)/100 total=m+tip+tax print("T