Python: Getting started with Python

Intention

Since JAVA has been overtaken by Oracle, it can’t be mistaken to get skilled with the basic concepts of Python. So this is my short Getting Started tutorial with my personal conclusion.

Instead of getting annoyed about the glorification of Python, it would be better to spend some time to have a short look at this programming framework.

In the most cases a language itself is not the crucial point, but it’s what it’s framework is providing for the developer.

So the most popular thing we hear about is the capabiliy that Python is good for…

  • Data Science
  • Arteficial Intelligence (especially the library Tensor flow)

Installation

To install Python, you have to go to https://www.python.org/downloads/ and download and install Python. The website is clearly arranged and you don’t have to spend much time to search for the correct runtime according to your needs.

After you have downloaded Python, a installation wizard guides you through the installation process in two steps. It catches to my eye that there are not so much options to choose except for the folder where you want to install it.

Getting started

So what do we need now… a development environment? Hmm… well because I have installed a Visual Studio 2013, i want to test the free „Python support for Visual Studio 2013), which can be found for different Visual Studio versions here:

https://github.com/Microsoft/PTVS/releases/v2.2.2

Python Tools for Visual Studio 2013 can be downloaded from GitHub

After the installation, there is a new Project Type available, when choosing

Visual Studio 2013 menu: File –> New Project

A new Python menu appears on the left side and we can choose to create a console application

After that you can immediatly start to code Python and press the Start-Button. Here is the „Hello World!“-Program:

A „Hello World!“-Program just consists one command.

What is a little bit weird is, that it doesn’t seems to matter if you use the following Syntax instead of the function-based print:

# This Python comment is like a UNIX Shellscript comment
print "Hello world!" # Is it possible to append a comment to the end?

# Is this really clean code if it doesn't matter how you write it?
print ("Hello world!") 

# How do you write multi line?
print ("Hello "
"world!") # this works without line break

print "Hello "
"world!" #this not

print """Hello 
 world!""" #this works but shows the line break

# without declarion of a variable
print "Number 1:";
x = input(); # My first Input 
print "Number 2:";
y = input("Here you can enter the input prompt:"); # My next Input 
print """

The result is:
==============
"""

print "The result is " + str(x + y) # working
# Python is not converting 
#automatically like C# when concatenating an Int to a String

print x #works
print y #works
print "A string for x: " + str(x) +"" #working 
print "A string for y: " + y +"" #not working 
#because he thinks that y is an Integer

In console applications it is possible to work simply with input and print. By experimenting a while you can find out what is working and what is not…
An input like „2“ will be automatically converted as an integer type (when it only contains an integer). It is possible to print the integers using the function (or command) „print“, but it is not possible to print an integer concatenated to a string.

My first conclusion

„Wenn Sie Python sehen wollen, dann gehen sie doch ins Dschungelcamp!“

Nico Gerbig in WhatsApp

For non programmers it seems to be really easy to write small console programs, but the language itself allows much syntax variants that i don’t would expect as clear readable code (especially in Python 2.7 what i have been used ).

But as shown in the following Screenshot newer python versions are a little bit more strict concerning procedure-based-programming.

In newer Python versions the BASIC-like command syntax is replaced by a real procedure syntax.

As you can see above, there is a small onboard IDE shipping with python that has a console in which it is possible to execute python code directly. Additionally it allows you to write programs in whole Python files by selecting the „File->New File“ in the menu.

The IDE can be found in the Start menu after installing a
Python package

One thing that makes me muse about the language concept is the missing option for variable declaration. Learing tutorials and guides are always promoting the omission of type-safe variable declaration as innovative concept and benefit in comparison to other common programming languages. I think it would be eligable to ask the question: „Why do non type-safe languages like JavaScript need a type-safe extension like TypeScript?“. Languages like Visual Basic (for applications) have introducted the „option explicit“ command to force the developer to do this … why? 🙂

Next steps

In further steps i want to find out how to point my Visual Studio to the newer Python framework. Python 3.8 is already installed but i do not have the choice to change it in Visual Studio. So i guess there must be a seperate configuration for this.

I am looking forward to evaluate the Tensorflow AI library and what benefit i can get from it.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.