Manipulated numbers.
This commit is contained in:
parent
bfef8d1013
commit
78520801ea
|
@ -300,6 +300,20 @@ You can manipulate lists with list comprehensions as well:
|
|||
fahrenheit = [celsius * (9 / 5) + 32 for celsius in celsius]
|
||||
```
|
||||
|
||||
### Print manipulated numbers in for loop
|
||||
```
|
||||
single_digits = range(10)
|
||||
squares = []
|
||||
cubes = [(num ** 3) for num in single_digits]
|
||||
|
||||
for single_digits in single_digits:
|
||||
print(single_digits)
|
||||
squares.append(single_digits ** 2)
|
||||
|
||||
print(squares)
|
||||
|
||||
print(cubes)
|
||||
```
|
||||
## Ranges
|
||||
|
||||
You can get a range of numbers using `range()`
|
||||
|
|
Loading…
Reference in New Issue