Loading topic
str, int, and float. You do not need any other background. Later chapters cover input, formatting, and files.2 min readstr, int and float, and have used print() with simple strings. It covers three ways to control what characters end up in a string: escape sequences, raw strings, and triple-quoted strings.2 min readstr, int and float. It also assumes you are comfortable with try and except. You have already used print() to write output. Now you will read text the user types.2 min readstr, int and float, and have used if statements and try/except. It covers what input() returns and how to convert that value into a number.2 min readwhile loops, try and except, and that input() returns a string. Users type unexpected things, and int() raises ValueError when it can't convert the text. Here you will catch that error and ask again instead of crashing.2 min readstr, int, and float, and have used print() and basic f-strings. It covers the two ways Python turns an object into text and how to choose between them.2 min readstr, int and float. It also assumes you have seen str() and repr() from the previous chapter. Python 3.6 or later is required for f-strings.2 min readstr, int, and float, and can run a Python script. Here you learn the format specification mini-language, the part after the colon in {value:spec}. It lets you line up columns, round numbers, and add separators without ex2 min readstr() and repr(), and can run a short Python script. The = specifier needs Python 3.8 or later.2 min read, separators). str.format() uses the same mini-language. Only the way you supply values differs.2 min read% operator in older scripts, in books written before Python 3.6, and in the logging module. You will rarely need to write it in new code, but you must be able to re2 min readstr.format(), dictionaries, and try/except. Here you will learn when string.Template is the safer choice and how to use it.2 min readprint() and input(), and read basic try/except code. It also assumes you have a terminal where you can run shell commands.2 min readstr and int, if and while, and try/except. You have already used print() for output and input() for input. Files work the same way, but the data lives on disk and persists after your program ends.3 min readopen() and a with block, and that you know the difference between str and bytes at a basic level. It covers two details that cause most "works on my machine" file bugs: which encoding turns text into bytes, and how line endings are translated.2 min read