3 HIDDEN SECRETS of Numbers in Python

preview_player
Показать описание
Think you know everything about numbers in Python? I bet there's at least one thing in this video about Python numbers that you haven't heard about before!

For example, did you know numbers have methods? Did you know Python booleans are actually integers? What about Python's number hierarchy? Have you ever heard of the Complex, Real, Rational, and Integral classes? Do you know how to make your own custom Python number types?

CHAPTERS
00:00 — Introduction
00:17 — Numbers have methods
04:38 — Numbers have a hierarchy
11:12 — Numbers are extensible
17:01 — Recap

RELEVANT LINKS

👨🏼‍🎓 WANT HELP LEARNING PYTHON?

ABOUT ME
Hi! I'm David Amos, a Python educator and author of Python Basics: A Practical Introduction to Python 3. I've worked as a professional programmer for over 8 years and have spent the last 3 years helping thousands of people learn Python and become better Python programmers. I'm also an avid Julia programmer and co-host of the @Talk Julia podcast.

#PythonProgramming #PythonProgrammingLanguage #NumbersInPython #Python #ProgrammingInPython
Рекомендации по теме
Комментарии
Автор

4:34 Why? Because the “.” is (mis)interpreted as a decimal point.

lawrencedoliveiro
Автор

3:47 The most recent revision of which, IEEE 754:2008, adds support for decimal floating-point formats, in addition to the older binary ones, precisely to get around this problem.

Now all we have to do is wait for numerics libraries and CPU hardware to catch up.

lawrencedoliveiro
Автор

0:22 You can leave off the “pretty much” proviso. Every value (something that can be computed by an expression or stored in a variable) is an object. Every object is an instance of a class. Functions and classes are also objects. So “def” and “class” blocks are not declarations, they are actually forms of assignment statement.

lawrencedoliveiro
Автор

Awesome video! Quite interesting :)
Really hope to see more of your videos!

prosecshane
Автор

9:15 Yes, Decimal is subject to floating-point representation error. A Decimal object still only has finite precision, after all. Try representing 1 ÷ 3 as a Decimal, and you should see what I mean.

lawrencedoliveiro
Автор

10:47 Just tried this:

>>> Decimal(1) / Decimal(3)

>>> Decimal(1) / Decimal(3) * Decimal(3)


Any questions?

lawrencedoliveiro
Автор

How are you getting those suggestions in Terminal ? Do we need to install any package?

MrMuraliS
Автор

Very nicely explained. I learnt new things today

pritam-kunduu
Автор

pretty random but I was curious how many 0s would be in the cut off for is_integer().. Do you the know the reason as to why 15 0s returns true. Ex: returns True

tombradyisagreekgod
Автор

What if you are checking to see if one float is greater than another float? in such cases, does it matter for most purposes?

wryltxw