Loading topic
float and int are. You have already seen import. Here you will use it for the math module.2 min readimport math before. Python has four common ways to turn a float into a whole number or a shorter float. They differ most on negative numbers and on halves.2 min readif statements, and that you can import a module as shown in the earlier chapters. It covers why float arithmetic gives odd results, how to compare floats safely, and how to add many floats accurately.2 min readint and float. The math module also has functions that work only on whole numbers. They return exact int results, however large, and they don't suffer the rounding problems that floats do.2 min readrandom module and the errors people most often make with them.2 min readimport, and that you have met random.randint and random.Random(seed). Here you will use four functions that work on whole sequences: choice, sample, choices, and shuffle.2 min readrandom.randint and random.choice. Here you will learn why "random" numbers can repeat exactly, and how to use that in tests and experiments.2 min readrandom.Random, seeding, and random.choice from the previous chapters. It also assumes you can build a string from a loop or a generator expression.2 min readfrom ... import ..., and can run a script or the interactive interpreter. It introduces the four core types in the datetime module. The next chapters cover arithmetic, formatting, and time zones in more depth.2 min readdate and datetime objects and know what a timedelta is, as covered in the previous chapter. It also assumes you are comfortable with basic Python operators.2 min readdate and datetime objects and do basic arithmetic with timedelta. Here you will convert those objects to text and text back to objects.2 min readdatetime objects, do arithmetic with timedelta, and use strftime and strptime. It covers the difference between naive and aware datetimes, and how to convert between time zones.2 min readmath, random, and datetime in one small program. It assumes you have read the earlier chapters on each module. You should know math.comb and math.ceil, seeded random.Random instances, and date plus timedelta arithmetic.2 min read