Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
About
People
Publications
Teaching
Resources
Research Blog
Wiki Functions
Recent changes
Help
Licensing
Page
Discussion
Edit
View history
Editing
Community Data Science Course/Day 1 Tutorial
(section)
From CommunityData
Jump to:
navigation
,
search
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.
Anti-spam check. Do
not
fill this in!
==Types== [[File:Geometry.png|150px]] There's a helpful '''function''' (more on what a function is in a second) called <code>type</code> that tells you what kind of thing -- what '''data type''' -- Python thinks something is. We can check for ourselves that Python considers '1' and '1.0' to be different data types: type(1) type(1.0) So now we've seen two data types: '''integers''' and '''floats'''. By the way, what is a "function"? Here are the important ideas about functions: * A function encapsulates a useful bit of work and gives that work a name. * You provide input to a function and it produces output. For example, the <code>type</code> function takes data as an input, and produces what type of data the data is (e.g. an integer or a float) as output. * To use a function, write the name of the function, followed by an open parenthesis, then what the function needs as input (we call that input the '''arguments''' to the function), and then a close parenthesis. * Programmers have a lot of slang around functions. They'll say that functions "take" arguments, or that they "give" or "pass" arguments to a function. "call" and "invoke" are both synonyms for using a function. In the example above, "type" was the name of the function. <code>type</code> takes one argument; we first gave <code>type</code> an argument of 1 and then gave it an argument of 1.0. ==== Diagram of "calling" a function ==== [[File:Function_diagram.png]] ===Command history=== Stop here and try hitting the Up arrow on your keyboard a few times. The Python '''interpreter''' saves a history of what you've entered, so you can arrow up to old commands and hit Return to re-run them!
Summary:
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)
Tools
What links here
Related changes
Special pages
Page information