Python For Rubyists, Part II: Data Types

Welcome back to this learn-quick series for Rubyists looking to learn Python! In case you missed it, you can check out Part I here.

Next up: Data Types.

Like most programming languages, Python has a few basic data types built in. Like in Ruby, you have strings, integers, and floats.

To convert between them, you can use the str(), int(), and float() functions. For example:

Here, we assigned the string "3" to the variable x. Then we converted it to an integer using int(). Then we…