Files

63 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: practical-python-1.3
source_exercise_id: "1.3"
title: "Cutting and Pasting"
section: "1.1 Python"
source_path: "01_Introduction/01_Python.md"
source_repo: "https://github.com/dabeaz-course/practical-python"
source_commit: "93dca856b41c61a0a0f85ae334116e4c125629ea"
student_visible_solution: false
has_private_solution: false
skip: false
---
# Exercise 1.3: Cutting and Pasting
> Source: Practical Python Programming, `01_Introduction/01_Python.md`.
### Exercise 1.3: Cutting and Pasting
This course is structured as a series of traditional web pages where
you are encouraged to try interactive Python code samples **by typing
them out by hand.** If you are learning Python for the first time,
this "slow approach" is encouraged. You will get a better feel for
the language by slowing down, typing things in, and thinking about
what you are doing.
If you must "cut and paste" code samples, select code
starting after the `>>>` prompt and going up to, but not any further
than the first blank line or the next `>>>` prompt (whichever appears
first). Select "copy" from the browser, go to the Python window, and
select "paste" to copy it into the Python shell. To get the code to
run, you may have to hit "Return" once after you’ve pasted it in.
Use cut-and-paste to execute the Python statements in this session:
```python
>>> 12 + 20
32
>>> (3 + 4
+ 5 + 6)
18
>>> for i in range(5):
print(i)
0
1
2
3
4
>>>
```
Warning: It is never possible to paste more than one Python command
(statements that appear after `>>>`) to the basic Python shell at a
time. You have to paste each command one at a time.
Now that you've done this, just remember that you will get more out of
the class by typing in code slowly and thinking about it--not cut and pasting.
## 关联来源
- [[summaries/01_Python]]