March 2020
Beginner to intermediate
342 pages
8h 38m
English
Python code is famously easy to read. It has even been described half-jokingly as “executable pseudocode.” For example, you can probably understand a lot of the following program, even if you have no Python experience at all:
| | # Import the square root function |
| | from math import sqrt |
| | |
| | |
| | # Return True if the argument is a prime number, False otherwise |
| | def is_prime(n): |
| | # n is prime if it cannot be divided evenly by any number in |
| | # the range from 2 to the square root of n. |
| | max_check_value = sqrt(n) |
| | # range(a, b) goes from a included to b excluded. Both a and b |
| | # must be integers, so we convert max_check_value to an integer |
| | # with the in-built int() ... |
Read now
Unlock full access