--Originally published at TEC GDL 2016
Dear reader,
Thank you for visiting my page once more. Today I will focus on the pure basics of the Python programming language. I will explain the different types there are in Python and what they are used for. Until this point I realized that I have not actually tried to understand the language of Python. Most times I just picked a random topic and started to write about it without actually trying to understand what I am doing. This starts NOW.
In Python, everything is an object. Each object is classified into different kinds of things. The way these objects are classified is to call them different classes or data types.
The main, so-called, native datatypes that are preinstalled in Python will further be explained one after another (this is only Part I of this series):
- Strings
Strings (denoted as ‘str‘, sequence of letters) are surrounded by quotation marks (single ‘, double ” or triple ”’ quotes).
The reason for this is, that when e.g. printing a sentence using an apostrophe (as is “I’m smart”), Python would confuse the single quotes. Thus, you would surround the string with double quotes.
(The same works the other way around: When you want to e.g. quote someone, use ‘ single quotes. Additionally, use triple quotes when framing a longer string.)
- Numbers (integers, floats)
Numbers are, of course, also often used within programs. In Python numbers are either classified as ‘int’ or ‘float’.
– ‘int‘ meaning integer numbers (like 1,2,3..)
– ‘float‘ numbers with a decimal point (like 1.25)
Python actually lets you find out what type a certain object is using the ‘type’ function.
See below:
- Boolean (True/False)
Booleans are either True or False. There are two constants installed within Python which can
Continue reading "Project 5: Basic Types & Their Use – Part I"