Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using Python

A short presentation about the basics of the programming language Python.

  • Login to see the comments

  • Be the first to like this

Using Python

  1. 1. Using Python or how to code snake language in windows
  2. 2. About Python…
  3. 3. Python is a common programming language…
  4. 4. It is used for a large variety of applications, for example, analytical software.
  5. 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.
  6. 6. Explanation time…
  7. 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. 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. 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. 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. 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. 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…
  13. 13. Now it’s time to install Python…
  14. 14. Start by going to https://www.python.org/downloads/...
  15. 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. 16. Finally it is just a matter of following the instructions given.
  17. 17. Even though Python has a large built in library, it lacks certain modules to ease the code-writing…
  18. 18. Therefore, we’ll now guide you through the process of installing more libraries to Python…
  19. 19. Start by downloading the library you want to install, we’ll install the wikipedia library in this tutorial…
  20. 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. 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. 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
  23. 23. That’s it! By Sebastian Grunditz and Samuel Håkansson

×