Unit 1 Flashcards

(28 cards)

1
Q

A namespace is:

A

a space in which names exist

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

If you want to import pi from math, which line will you use?

A

from math import pi

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

Which one of the following is true?

A

packages contain modules

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

What can you do to indicate that a module entity should be treated as private?

A

A. you can mark the entity name with the _ (single underscore) prefix

B. you can mark the entity name with the __ (double underscore) prefix

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

A PWG-lead repository, collecting open-source python code is called:

A

PyPl

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

PyPl i often referred to as:

A

Cheese Shop

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

The name pip comes from:

A

pip installs packages

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

What is true about pop?

A

A. it’s a command-line tool

B. there are two different pip implementations, one for Python 2 and the other for Python 3

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

When you use pip to install a package that requires one or more dependencies, then:

A

pip will take care of everything by itself

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

Which of the following commands will you use to determine your pip version

A

A. pip -version
B. pip version
C. pip –version

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

The pip install command presents a list of:

A

locally installed packages

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

from random import randint

for i in range (2):
print(randint(1, 2), end=” “)

prints a number 2 times with a randomly generated num between 1 and 2, with only a space between the 2 singular numbers

A

11, 12, 21, or 22

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

the pyc file contains:

A

compiled Python code

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

What is true about updating already installed Python Packages?

A

its performed by the install command accompanied by the -U option

use -U to update an existing package

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

During the first import of a module, Python deploys the pyc files in the directory called:

A

pycache

pyc = pycache

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

A predefined Python variable that stores the current module name is called:

17
Q

a list of package’s dependencies can be obtained from pip using its command named:

18
Q

How to use pip to remove an installed package?

A

pip uninstall package

19
Q

Knowing that a function named fun() resides in a module named mod, and it has been imported using the following line:

import mod

Choose the way it can be invoked in your code:

20
Q

What is true about the pip install command

A

A. It allows the user to install a specific version of the package
B. it install a package per user only when the –user option is specified

21
Q

a function which returns a list of all entities available in a module is called:

22
Q

What is true about the pip search command?

A

A. all its searches are limited to locally installed packages
B. it searches through all PyPl packages
C.it needs working internet connect to work

23
Q

Choose the true statements:

A

A. The version function from the platform module returns a string with your OS version

B. The system function from the platform module returns a string with your OS name

24
Q

from a.b import c

causes the import of:

A

entity c from module b from package a

25
import math result = math.e != math.pow(2, 4) print(int(result))
A. 1 when a the boolean True is set as an integer it returns 1
26
Knowing that a function named fun() reside in a module named mod, choose the correct way to import it:
from mod import fun
27
When a module is imported, its contents:
are executed one (implicitly)
28
The digraph written as #! is used to:
tell a Unix-like OS how to execute the contents of a python file.