-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreadme.html
97 lines (97 loc) · 3.28 KB
/
readme.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=yes"
/>
<title>readme</title>
<style type="text/css">
code {
white-space: pre-wrap;
}
span.smallcaps {
font-variant: small-caps;
}
span.underline {
text-decoration: underline;
}
div.column {
display: inline-block;
vertical-align: top;
width: 50%;
}
</style>
</head>
<body>
<h1 id="practice-exercises-for-external-packages">
Practice Exercises for external packages
</h1>
<h2 id="overview">Overview</h2>
<p>
In this section, you’ll have a chance to practice the concepts you’ve
learned in the videos. First, review the core concepts covered that you’ll
need to keep in mind. Then go through the exercises below.
</p>
<p>
Remember, these are for your own benefit. Feel free to skip them if you
don’t find a particular exercise valuable or you get stuck for too long.
</p>
<h2 id="core-concepts">Core concepts</h2>
<h3 id="requirements.txt">requirements.txt</h3>
<p>
When working with an application that uses external packages, you need to
communicate what packages are required for it to run. We do this with a
<code>requiements.txt</code> file, here is an example:
</p>
<pre><code>colorama
prompt_toolkit</code></pre>
<p>
Once you have a virtual environment active, you can install all the
dependencies with this command:
</p>
<pre><code>(env) C:\> pip install -r requirements.txt</code></pre>
<h3 id="virtual-environments">Virtual environments</h3>
<p>
Virtual environments are key to having different versions of the same
library coexisting on your computer. You create one as follows:
</p>
<h4 id="macos-linux">macOS / Linux</h4>
<pre><code>$ python3 –m venv venv
$ . venv/bin/activate</code></pre>
<h4 id="windows">Windows</h4>
<pre><code>C:\> python –m venv venv
C:\> venv\scripts\activate</code></pre>
<h3 id="pip">pip</h3>
<p>
Pip is the tool you use on the command line to install and view external
packages. Here are some examples:
</p>
<pre><code>$ pip list
$ pip install colorama
$ pip install -r requirements.txt
$ pip uninstall requests</code></pre>
<h2 id="exercises">Exercises</h2>
<p>
Now it’s your turn. In this practice, go back to the tic tac toe game we
created back in the chapter on problem solving. Alternatively, if you made
it through Connect 4, you can work with that one instead. Your job will be
to:
</p>
<ul>
<li>Create a virtual environment.</li>
<li>
Set it as the active python interpreter in PyCharm under
<code>settings > project > project interpreter</code>.
</li>
<li>
Create a requirements.txt file with <code>colorama</code> as a
dependency.
</li>
<li>Install the requirements with <code>pip</code>.</li>
<li>Use <code>colorama</code> to add colored output to your game.</li>
</ul>
</body>
</html>