COMP10001 Lecture Notes - Lecture 3: Hexadecimal, Local Variable

55 views1 pages
define variable
-
arity functions by specifying default values for arguments (x=n)
-
function variables are not accessible from outside the function call
functions can access variables defined outside
each function call defines its own local variable scope
-
Functions:
-
called as object.method()
-
.upper() = return in all uppercase
.lower() = return in all lowercase
.strip(string) = return with all instances of characters in string (whitespace if no string)
removed from start and end
useful methods
-
Methods:
insert variables into string by indexing relative to the arguments to format
-
.format()
-
f = float
d = decimal integer
x = hexadecimal (base
-
16) integer
o = octal (base
-
8) integer
b = binary (base
-
2) integer
format specifiers
-
Strings and formatting:
tool to make the computer do something over and over again
-
a = a + 1
for i in "abc":
print(a)
e.g. a = 0
for loops
-
range(start, end, step) = generate a sequence of int values from start (inclusive) to end (non
-
inclusive), counting step at a time
-
while loops
-
break ends while loops and bypasses the condition in the while statement
-
Iteration:
use ( , ) to build them
-
used to represent multi
-
variate objects
-
to return multiple values
to swap values between variables
to test for one of a series of values
as keys to dictionaries
useful applications
-
immutable (cannot change elements)
-
Tuples:
Week 3
Wednesday, 21 March 2018 10:23 PM
Foundations of Computing Page 1
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 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

Related Documents