Editing Community Data Science Workshops (Spring 2015)/Day 0 tutorial

From CommunityData

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 51: Line 51:
</syntaxhighlight>
</syntaxhighlight>


Hey now! That last result is a little strange. When you divide a number in Python, even if the answer doesn't need a decimal place (like <code>4/2</code> which equals 2), you get an answer with a decimal point!
Hey now! That last result is a little strange. When you divide number, even if the answer doesn't have a decimal place, you get an answer with a decimal point! What's going on here is that in Python (version 3, at least), division produces an what's called a <code>float</code> which essentially means a number with a decimal point.


What's going on here is that in Python, division produces an what's called a <code>float</code> which essentially means a number with a decimal point.
When the Python interpreter goes to do the division, it knows that (unlike multiplication for example) division can lead to numbers that aren't whole numbers (like <code>1/2</code>) so it means that the result will always include a decimal place.
 
When the Python interpreter goes to do the division, it knows that (unlike multiplication for example) division can lead to numbers that aren't whole numbers (like <code>1/2</code>) so it makes sure that the result will always include a decimal place just in case it's needed.
 
 
This shouldn't be important for this workshop but it might be worth knowing that older versions of Python (before version 3) would always round down and return integers instead of giving numbers with decimal places.


==Types==
==Types==
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see CommunityData:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)