1. Data Types

This is a list of datatypes along with their short name and examples of how to use them:
[table id=1 /]
Numbers
Once we have our Python environment setup we can execute numerical calculations and obtain their results
Addition
4 + 4
= 8
Multiplication
2 * 2
= 4
Division
5 / 2
= 2.5
Division
7 / 4
= 1.75
Modulo or “Mod” can be used to find the remainder of a division operation
7 % 4
= 340 % 4
= 0
Power
2 ** 3
= 8
Order of Operations
2 + 3 * 4 + 2
= 16(2 + 3) * (4 + 2)
= 30
Strings
Strings are ordered sequences of characters, and we use single or double quotes to identify them.
Single quotes
‘hello’
Double quotes
“Hello
We can use double quotes to help when our string is a phrase that contains a single quote
“What’s up!”
Index
[cc lang=”python” width=”100%”]
import sys
#you can also assign individual arguments to a variable
serverip=sys.argv[1]
for commandlineargument in sys.argv:
print(“argument=”+commandlineargument)
#output
”’
python3 arguments.py myArgument1 myArgument2
argument=arguments.py
argument=myArgument1
argument=myArgument2
[/cc]
Comments are closed.