Share your repls and programming experiences

← Back to all posts
Python Coding Challenge series-1

Welcome to the python coding challenge series-1

Topic -

  • Create a python math application with only 10 lines of code - don't use comments!

Share your link of the repl in comments -

Recieved repls -

The best one would be the winner of this series!

10 upvotes for announcing the winner!


cool, @henryeth, but as ima beginner at python, can u pls tell me why is str used?

henryeth (180)

@CaptinNeo thanks. str() is an in built Python function that attempts to convert its argument to string type. In this case, I use it because I am concatenating the result to another string as the output, and because coercion does not exist in python, if I try to do [string] + [integer] it will raise an exception (error). So I need to convert the integer to a string before I concatenate them.


I understood it @henryeth, but why did you use int() 2 times together?

henryeth (180)

@CaptinNeo Even better question! I do that to round the result of the calculation. The second int() encloses the input() and the first encloses the whole calculation. If I didn't do that, any whole number outputs would come out as [integer].0 which I didn't want, so I took the route of rounding all of them.


oh yeah, @henryeth

plant3jyyehejy (14)

This could be made in 3 bars