Chapter 1 code segment Flashcards

1
Q

Snippet

A

A small region of re-usable source code, machine code, or text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Terminal

A

Text-based interface to the computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Type ipython on terminal and press Enter to enter interactive mode

A

Get:
Python 3.7.0 | packaged by condo-forge | (default, Jan 20 2019, 17:24:52)
Type ‘copyright’, ‘credits’ or ‘license’ for more information
IPython 6.5.0 — An enchanced Interactive Python. Type ‘?’ For help.

In [1]

Here [1] is prompt, indicating that IPython is waiting for your input. Can type math equation if you want to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Integers

A

Whole numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Floating-point numbers

A

Whole n umbers with decimal points

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

To exit interactive mode

A

<Ctrl> + d (or <control> + d)
This displays the prompt “Do you really want to exit ([y]/n)?” The square brackets around y indicate that it’s the default response-pressing Enter submits the default espouse and exits
</control></Ctrl>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

To exit interactive mode on Linux or macOS type what?

A

Type <Ctrl>+d(or<control>+d) twice</control></Ctrl>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In IPython interactive mode, you’ll need small bits of Python code called ______ and immediately see their results

A

Snippets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In IPython ________ mode, you’ll execute Python code loaded from a file that has the .py extension (short for Python)

A

Script

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Evaluate the expression 5 * (3 + 4) both with and without the parenthesis. Do you get the same result? Why or why not?

A

You get different results because snippet [1] first calculates 3 + 4, which is 7, then multiplies that by 5. Snippet [2] first multiplies 5 * 3, which is 15, then adds that 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does it mean if a file name ends in .py?

A

The .py extension indicates that the file contains Python source code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Variables

A

Stored values for later use in your code. Ex:
In [1]: x = 7
These are known as statements, it is a specified task to perform. The entire statement is an assignment statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Assignment symbol

A

In the variables example, this is (=)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Addition operator

A

+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Binary operator

A

Has two operands such as x + y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A