Programmeren
Assignment 1
Assignment 1
Chapter 1
#summing
print (3 + 2)
5
#subtracting
print (7 - 1)
6
#multiplication
print (3 * 3)
9
#division
print ()
3
#power
print (5 ** 2)
25
#percentage
print (10 % 3)
1 (3x3x3 = 9, hou 1 over)
Chapter 2
a_string = 'test' (for representing text)
an_integer =4 (for representing whole numbers)
a_float = 3.14 (for representing numbers with decimals)
a_tuple = (2,5) (for representing immutable combinations of values)
a_list = [1,2,3,1,2,3,'a','b','c'] (for representing ordered sequences of objects)
a_set = {1,2,3,4,'apple'} (for representing unordered sets of objects)
a_dict ={x} (to represent mappings between objects)
a_function = print (to manipulate objects, or to produce new objects given some input )
a_bool = True (to represent the truth values True or False)
, Chapter 3
Chapter 4
Comparison operators
Operator Meaning True False
== Equal 2 == 2 3=2
!= Not equal 3 != 2 2 != 2
< Less than 2 < 13 2<2
<= Less than or equal to 2 <= 2 3 <= 2
> Greater than 13 > 2 2 > 13
>= Greater than or equal to 3 => 2 2 >= 3
Membership operators
Operator Function True False
in Left object is a member of right object 2 == 2 3=2
not in Left object is NOT a member of right object 3 != 2 2 != 2
And, or and not
Operation Function
bool1 AND bool2 True if bool1 and bool2 are True, otherwise False
bool1 OR bool2 True when at least one of the boolean expressions is True, otherwise False
NOT bool1 True if bool 1 is False, otherwise False
Assignment 1
Assignment 1
Chapter 1
#summing
print (3 + 2)
5
#subtracting
print (7 - 1)
6
#multiplication
print (3 * 3)
9
#division
print ()
3
#power
print (5 ** 2)
25
#percentage
print (10 % 3)
1 (3x3x3 = 9, hou 1 over)
Chapter 2
a_string = 'test' (for representing text)
an_integer =4 (for representing whole numbers)
a_float = 3.14 (for representing numbers with decimals)
a_tuple = (2,5) (for representing immutable combinations of values)
a_list = [1,2,3,1,2,3,'a','b','c'] (for representing ordered sequences of objects)
a_set = {1,2,3,4,'apple'} (for representing unordered sets of objects)
a_dict ={x} (to represent mappings between objects)
a_function = print (to manipulate objects, or to produce new objects given some input )
a_bool = True (to represent the truth values True or False)
, Chapter 3
Chapter 4
Comparison operators
Operator Meaning True False
== Equal 2 == 2 3=2
!= Not equal 3 != 2 2 != 2
< Less than 2 < 13 2<2
<= Less than or equal to 2 <= 2 3 <= 2
> Greater than 13 > 2 2 > 13
>= Greater than or equal to 3 => 2 2 >= 3
Membership operators
Operator Function True False
in Left object is a member of right object 2 == 2 3=2
not in Left object is NOT a member of right object 3 != 2 2 != 2
And, or and not
Operation Function
bool1 AND bool2 True if bool1 and bool2 are True, otherwise False
bool1 OR bool2 True when at least one of the boolean expressions is True, otherwise False
NOT bool1 True if bool 1 is False, otherwise False