1. Data Types

This is a list of datatypes along with their short name and examples of how to use them:

NameTypeDescription
IntegersintWhole numbers, such as: 5, 98, 36234
Floating Point IntegersfloatNumbers with a decimal point: 5.34, 44.33, 1.0
StringsstrOrdered sequence of characters: "hello world", 'John', "100.0" "Saltwater Café"
ListslistOrdered sequence of objects: ["hello",10.00,"world"]
DictionariesdictUnordered Key:Value pairs: {"firstName":"Jane","lastName":"Smith"}
TuplestupOrdered immutable sequence of objects: ("hello",44,"world")
SetssetUnordered collection of unique objects: {"a","b","d"}
BooleansboolLogical value indicating True or False

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
= 3

40 % 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

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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