Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 78504ac

Browse files
Replace % with f-string in basics/modules.md (#40)
1 parent 22725a4 commit 78504ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎basics/modules.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ for thing in things:
369369
```
370370

371371
Measure how long it takes for the user to answer a question.
372-
The `%.2f` rounds to 2 decimals, and you can find more formatting
373-
tricks [here](https://pyformat.info/).
372+
The `{:.2f}` rounds to 2 decimals, and you can find more formatting
373+
tricks [here](https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals).
374374

375375
```python
376376
import time
@@ -381,7 +381,7 @@ end = time.time()
381381
difference = end - start
382382

383383
if answer == '3':
384-
print("Correct! That took %.2f seconds."% difference)
384+
print(f"Correct! That took {difference:.2f} seconds.")
385385
else:
386386
print("That's not correct...")
387387
```
@@ -410,7 +410,7 @@ Check what a path points to.
410410
import os
411411
import sys
412412

413-
print("You are currently in %s."%os.getcwd())
413+
print(f"You are currently in {os.getcwd()}.")
414414

415415
while True:
416416
path = input("A path, or nothing at all to quit: ")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /