FIT1045 Lecture 2: Week 2

59 views2 pages
Comparison ops
!"#$%$&'
(( $)*+,
-
.( "/#0$)*+,
-
1,/+#'
((02/$'"3#04/&50'/04$,,0+,,0#6$0#78$90
+0:/*;,$0$<#&+0='0+#0#6$0$"20/>0?@===
A0:/*,20:6+"%$0/*#;*#
-
abs(0.999999999 -1)
< 1.0e-10
-
B#&7"%'
CD#6/"07'0:+'$0'$"'7#7E$@
-
x in s F#&*$07>0<07'0+0'*G'#&7"%0/>0'0
H+"20E7:$0E$&'+I
J$##$&'0"$$20#/0G$07"0'$)*$":$0
+"20:+'$0'$"'7#7E$.
-
!"2$<$'0/>0$"#7&$0'$#0/>0KCCLMNOBL0
JLPPLMB07'0,/4$&0#6+"07"2$<$'0/>0
$"#7&$0'$#0/>0,/4$&:+'$0,$##$&'0H+5+0
O:'770E+,*$'I
-
Boolean expressions
(0$<;&$''7/"'0#6+#06+E$0E+,*$'0True />0
False
(Learning1outcome12)
N/8;+&$07"#$%$&'90>,/+#'0+"20'#&7"%'
!"#&/2*:$0Q//,$+"0$<;
!"#&/2*:$0'$,$:#7/"
Selection
(07>90$,'$7>90$,'$
if boolean_expression:
block
if boolean_expression:
block1
else:
block2
if boolean_expression1:
block1
elif boolean_expression2:
block2
elif boolean_expression3:
block3
elif boolean_expression4:
block4
else:
last_block
Iteration
for, while
for each number in a
sequence of numbers
Do something
for each item in some List
Do something
for each character in some
string
Do something
for each line in some files
Do something
for variableName in XXXX:
Do something
while boolean_expression:
block
N+"0*'$0>/&07">7"7#$0,//;'
Magic numbers
R+%7:0E+,*$0(0"H"STUI0V0S
range(stop)
!#$&+#$'0/E$&07"#$%$&'07"0W?9'#/;I
for number in range(10):
print(number*number)
range(start,stop[,step])
X$>+*,#0'#$;0'7Y$0U
for number in range(3,9)
print*number)
3
4
5
6
7
8
for value in range(12,0,-2):
print(value)
12
10
8
6
4
2
Reading1text1files
Writing1text1files
Week$2
R/"2+D90ZU0[*,D0S?U\
US]?^
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers