2- how python runs programs Flashcards

1
Q

What really happens when a python program runs?

A

first the source is complied into bytecode, then this is routed to the virtual machine

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

The compiler creates a new file, what is the extension?

A

.pyc

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

In python 3.2 and later, the bytecode files are saved in what directory?

A

__pychache__

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

what does Python check to see if the bytecode files need to be updated?

A

The last modified timestamps of both the source and the byte code files. It also check the version of Python from the byte code.

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

can Python run a program with only bytecode files ( no source)

A

yes

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

What is a namespace?

A

package of variable names

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

what is a module

A

it’s just a .py file.

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

When a module is imported, what is the last thing that is done?

A

it’s run.

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

what are names within packages called?

A

attributes. These are simply variable names for specific objects.

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

what is the difference between import an from

A

from does one extra thing. From copies a modules attributes, so that they become variables in the recipient.

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

what is the syntax to use from in a file called test1 and a attribute called blaster

A

from test1 import blaster

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

what function prints an imported module’s names in a list

A

dir

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

What is the python conceptual hierarchy?

A

Programs are composed of modules. Modules contain Statements. Statements contain expressions. Expression create and process objects.

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