![]() |
![]() |
|
home—info—lects—labs—exams—hws
—D2L—breeze (snow day)—tutor/PIs
Examples:
Updated list: In Python, we have several types of values:
Even if we don't really know what
import string # This loads the entire library of string functions. Only needed once per session. string.capitalize("hello") # The name of the function is kind of long, because it includes the library-name at the start: “string.capitalize” |
hint: Looking at the web-page from the previous step, can you find a different1 function, which computes the square-root? Can you call that function, giving it the number 2, as its input?
The last example — the square root of two — illustrates one more type of data that python has: “floating point numbers”, which is a number with a decimal-point2. They commonly called “float”s or “double”s3.
Updated list: In Python, we have several types of values:
1
If you're a math whiz, you might realize
that square-root is actually just a special-case of raising-to-a-power;
you could compute the square-root of 2 just by using
2 It turns out, inside the computer the decimal-point can “float around”, hence the name. ↩
3 “double” is short for “double-precision floating-point”. But these days, single-precision floating-points are hardly ever used, which is why “double” has become a synonym for floating-point numbers. ↩
home—info—lects—labs—exams—hws
—D2L—breeze (snow day)—tutor/PIs
©2013, Ian Barland, Radford University Last modified 2014.Jan.27 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |