June 2017
Beginner to intermediate
274 pages
6h 49m
English
The third major building block of Python programs is expressions. We've seen expressions in every example so far because it's nearly impossible to do anything in Python without using expressions.
Expressions consist of data values and operations to perform on those data values. The very simple expressions are a single data value and with no operations, for example, a single number. More complex expressions involve at least one operation and probably more data values as well, for example, adding two numbers or calculating the area, as shown in the following code example:
import math def example_function(name: str, radius: float) -> str: area = math.pi * radius ** 2 return "The area of {} is {}" .format(name, area) print(example_function('Bob', ...Read now
Unlock full access