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

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 8 basics/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ for thing in things:
```

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

```python
import time
Expand All @@ -381,7 +381,7 @@ end = time.time()
difference = end - start

if answer == '3':
print("Correct! That took %.2f seconds." % difference)
print(f"Correct! That took {difference:.2f} seconds.")
else:
print("That's not correct...")
```
Expand Down Expand Up @@ -410,7 +410,7 @@ Check what a path points to.
import os
import sys

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

while True:
path = input("A path, or nothing at all to quit: ")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.