4. It is used for a large variety of applications,
for example, analytical software.
5. Code
import os
x = os.getcwd() #Assigns the current directory to x
print(x)
-------------------------------------------------------------------------------------
Output
C:UsersSebastianDownloads
A simple Python program looks like
above.
7. Code
import os
x = os.getcwd() #Assigns the current directory to x
print(x)
-------------------------------------------------------------------------------------
Output
C:UsersSebastianDownloads
The purples are statements. The import statement tells the computer to grab
a prewritten piece of code and implement it easily…
8. Code
import os
x = os.getcwd() #Assigns the current directory to x
print(x)
-------------------------------------------------------------------------------------
Output
C:UsersSebastianDownloads
The greens are modules. Modules are a way to write code so that you can
implement it easier in other parts of your code…
9. The reds are variables. The x is here assigned to the value of os.getcwd().
Variables are a way to store data that will be used later, either, for example,
for calculations, or for text manipulation…
Code
import os
x = os.getcwd() #Assigns the current directory to x
print(x)
-------------------------------------------------------------------------------------
Output
C:UsersSebastianDownloads
10. Code
x = ‘Hello you’ #x is now a string-variable
y = 7 #y is now a number-variable
print(x)
print(y)
-------------------------------------------------------------------------------------
Output
Hello you
7
Here’s a visual demonstration of different kinds of variable values and how
the values are stored to a variable. The ‘Hello you’ is a string, and the 7
is an integer, shortened int…
11. Code
import os
x = os.getcwd() #Assigns the current directory to x “””
print(x)
-------------------------------------------------------------------------------------
Output
C:UsersSebastianDownloads
The grey are comments. The # represents a single line comment, which is
used when there needs to be a quick explanation, such as above. There is also
the “””…“”” which is a multiline comment, mostly used to comment away
sections of code that isn’t used. The comments does nothing when the
program runs…
12. Code
import os
x = os.getcwd() #Assigns the current directory to x
print(x)
-------------------------------------------------------------------------------------
Output
C:UsersSebastianDownloads
And finally, the blues are functions. Functions is a block of organized, reusable
code that is used to perform a single, related action. Functions provide better
modularity for your application and a high degree of code reusing…
15. Then click the download button for the version of Python you
want, we are using Python 3.4.* for the code in this
presentation…
16. Finally it is just a matter of following the
instructions given.
17. Even though Python has a large built in library, it
lacks certain modules to ease the code-writing…
18. Therefore, we’ll now guide you through the
process of installing more libraries to Python…
19. Start by downloading the library you want to install,
we’ll install the wikipedia library in this tutorial…
20. If there is a .exe file to download, download and run it, and it’s
installed. Otherwise, download the .gz.tar file and unzip it to the
folder where Python is, using e.g. WinRAR…
This is what my
Python folder
looks like.
21. After that it’s time to start the old CMD. When it’s started,
navigate to the Python folder, it should look something like the
picture above…
22. Now it’s time to install the library. Type in the code shown above in to CMD to
start the installation, but remember to type in the name of the library you’re
installing instead of wikipedia…
Python –m pip install wikipedia