Python
Interactive Mode & First Steps
20 flashcards · answers and spaced-repetition review in the KnowCard app
What does this scientific-notation literal evaluate to, and what type is it?
```
>>> 12.345e3
```
You type a literal at the >>> prompt and want to know its data type without guessing. What do you do?
At the >>> prompt you type a bare expression and press Enter. What does the interactive interpreter do with the result?
The REPL auto-echoes a string differently from how print shows it. What does each line below produce?
```
>>> "Hello World"
>>> print("Hello World")
```
In the interactive mode, what does the underscore _ refer to, and where does this NOT work?
An assignment like x = 5 is a statement, not an expression. What does the REPL print right after you enter it?
What does `+` do for strings and for lists at the prompt? Predict both:
```
>>> "Hello" + " World"
>>> [1, 2] + [3, 4]
```
After x = ["Python", "is", "great"], what does x[0] return — and what's the off-by-one trap?
Assigning to a dictionary key that doesn't exist yet — what happens?
```
>>> d = {"key1": "value1"}
>>> d["key3"] = "value3"
```
The book's examples use (3 < 4) and (5 < 6). What value does a comparison like 3 < 4 evaluate to in the REPL?
What does not (3 < 4) evaluate to, and what equivalent comparison does the book give for it?
You want to print a label and a value on one line: print("The number is:", var) with var = 9. What exactly is printed?
How do you call the sort method on a list, and what does the call itself return?
```
>>> nums = [3, 1, 2]
>>> nums.sort()
```
Before using the pprint module's function in the REPL, what must you do — and how do you then call it?
What does each division print in Python 3?
```
>>> 3 / 2
>>> 3 // 2
```
The book keeps using the word "literal" (as in "a string literal" or "a numeric literal"). What precisely does that term mean?
You just typed a long line at the >>> prompt and want to run a slight variation of it. What's the fastest way to get it back without retyping the whole thing?
Besides the bare interpreter, every Python install ships a second tool with a GUI for editing and running programs. What is IDLE, and what conveniences does it give you?
In the REPL you type if x > 10: and press Enter. The prompt changes and no code runs yet. What changed, and how do you signal that the block is finished?
You start the Python interpreter with no command-line arguments and get a >>> prompt. What is this mode called, and what is it deliberately NOT meant for?
Start learning today
Free to start — download the app or use it in your browser.
