Difference between revisions of "Python"
From Centre for Bioinformatics and Computational Biology
(Created page with "=== Variables === ==== Integers and Floats ==== ==== Booleans ==== ==== Strings ==== ==== Lists ==== ==== Tuples ==== ==== Sets ==== ==== Dictionaries ====") |
(→Variables) |
||
Line 1: | Line 1: | ||
=== Variables === | === Variables === | ||
+ | Variables allow you to store and change values based on certain conditions. In many low level languages like C, C++ and Java when declaring a variable it is required that you also specify of what type it will be. This type is then static and will never change. In java for example declaring a variable that will in the future store a number looks like this: | ||
+ | |||
+ | <source lang="java"> | ||
+ | int some_number; | ||
+ | </source> | ||
+ | |||
+ | Many scripting languages, like python, are weakly or loosely type. This means that you are not required to asign a type to a variable when you create this. Variable can also easily change types. This makes the language extremely flexible, but it become easy to get confused with what type a variable is. | ||
+ | |||
+ | It is thus recommended that you type variables. An example of typing in python: | ||
+ | <source lang="python"> | ||
+ | some_number: int | ||
+ | </source> | ||
+ | |||
==== Integers and Floats ==== | ==== Integers and Floats ==== | ||
==== Booleans ==== | ==== Booleans ==== |
Revision as of 06:19, 20 June 2019
Contents
Variables
Variables allow you to store and change values based on certain conditions. In many low level languages like C, C++ and Java when declaring a variable it is required that you also specify of what type it will be. This type is then static and will never change. In java for example declaring a variable that will in the future store a number looks like this:
int some_number;
Many scripting languages, like python, are weakly or loosely type. This means that you are not required to asign a type to a variable when you create this. Variable can also easily change types. This makes the language extremely flexible, but it become easy to get confused with what type a variable is.
It is thus recommended that you type variables. An example of typing in python:
some_number: int