39 lines
1.2 KiB
Markdown
39 lines
1.2 KiB
Markdown
---
|
|
id: practical-python-2.12
|
|
source_exercise_id: "2.12"
|
|
title: "Formatting Challenge"
|
|
section: "2.3 Formatting"
|
|
source_path: "02_Working_with_data/03_Formatting.md"
|
|
source_repo: "https://github.com/dabeaz-course/practical-python"
|
|
source_commit: "93dca856b41c61a0a0f85ae334116e4c125629ea"
|
|
student_visible_solution: false
|
|
has_private_solution: false
|
|
skip: false
|
|
---
|
|
|
|
# Exercise 2.12: Formatting Challenge
|
|
|
|
> Source: Practical Python Programming, `02_Working_with_data/03_Formatting.md`.
|
|
|
|
### Exercise 2.12: Formatting Challenge
|
|
|
|
How would you modify your code so that the price includes the currency symbol ($) and the output looks like this:
|
|
|
|
```
|
|
Name Shares Price Change
|
|
---------- ---------- ---------- ----------
|
|
AA 100 $9.22 -22.98
|
|
IBM 50 $106.28 15.18
|
|
CAT 150 $35.46 -47.98
|
|
MSFT 200 $20.89 -30.34
|
|
GE 95 $13.48 -26.89
|
|
MSFT 50 $20.89 -44.21
|
|
IBM 100 $106.28 35.84
|
|
```
|
|
|
|
[Contents](../Contents.md) \| [Previous (2.2 Containers)](02_Containers.md) \| [Next (2.4 Sequences)](04_Sequences.md)
|
|
|
|
## 关联来源
|
|
|
|
- [[summaries/03_Formatting]]
|