How to transform a float 50.0 into an int 50 in Python?

i need a function that should looks like this:

>>> a = 5.0
>>> integer(a)
>>> 5


Just make it an int:


And don't call the variable the same name as the module, otherwise you can't access the module anymore. That's why I used r instead.

That said, your comparison should work anyway, because Python is smart:

>>> 5.0 == 5

Finally, since you apparently want a multiple of 10 from 0 to 90, I'd just do this:

int(random.random() * 10) * 10

Need Your Help

Setting Java generics of iterators

java generics for-loop iterator

I've noticed something funny Java does (or at least Netbeans) when I use classes implementing ArrayList and changing the generics type of the elements. I basically created an abstract class that ex...

What is DoAuthorization in Paypal for?

paypal paypal-sandbox

I am doing test regarding Paypal sandbox server about Express Checkout, and found the following weird situation.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.