Assignment 1 Flashcards
week 1/2/3 excluding lecture 1.1
Arithmetic Operations on Python
1) addition (+), subtraction (-), multiplication (*), division (/)
2) exponent (**)
3) integer division (//)
4) remainder (%)
Operation on strings
+ or *
Cannot add different variable types
Variable types
String
Integer
Float
Boolean
int(value)
string(value)
float(value)
changes value to int/string/float
Python is case sensitive and avoid using keywords as variable names
Relational operators?
<, >, <=, >=, ==, !=
Relational operators
in, not in
string operators
eg: ‘app’ in ‘apples’ returns TRUE
eg: ‘bbc’ in ‘apples’ returns FALSE
eg: ‘abp’ in ‘apples’ returns FALSE
Boolean operators
or
and
not
Boolean operators precedence
not -> and -> or
Precedence of ALL operators
()
**
+x/-x (positive/negative)
*, /, //, %
+, -
relational operators
not -> and -> or
print() and input()
\n
new line
\t
tab
\
inserts backslash