This summary contains all the information of the Lectures and the slides of the lectures the wednesday tutorials with examples of codes.
This is a summary of the subject Algorithms and data structures in Python at The University of Amsterdam.
Declarative knowledge = statement of fact
Imparative knowledge = a recipe or “how to”
This is used by machines. “Machines are stupid”
Recipe -> 1. Sequence of simple steps.
2. Flow of control process that specifies when each step is executed.
3. A means of determining when …
Computers
You got two different kind of computers:
- Fixed program computer (calculator)
- Stored program computer (machine stores)
Basic machine architecture
Basic primitives
Tuning -> Compute anything using 6 primitives
- Right
- Left
- Read
- Wright
- Scan
- Do nothing
Nowadays, modern programming have more primitives. We can even use abstract methods to
create knew primitives.
! Anything that is computable in one programming language is computable in any other
programming language.
Pagina 1 van 83
,Creating recipes
- A programming language provides a set of primitive operations
- Expressions are complex but legal combinations of primitives in a programming language
- Expressions and computations have values and meanings in a programming language
Languages
You have different kind of languages. For instance english consists of words while programming
language consists of strings, floats, integers, booleans etc.
String = “Hello” -> words ()
Integer = 256 -> hele nummers ()
Float = 8.5 -> komma getallen ()
List = [1,2,3,4,] -> een lijst aan strings, integers, floats etc. [ ] (tuple is same but with ( ) )
Dictionary = { “a” = “apple”, “b” = “banana”} { }
Boolean = TRUE, FALSE
Om te zien wat voor type een bepaalde variable is: type(“Hello”) = <type ‘str’>
- Syntatic errors, are errors which are common and easily caught.
- Static semantic error = Some languages check for these before running the program
Can cause unpredictable behavior
Pagina 2 van 83
,Sometimes you don’t get any semantic errors but the programmer get different meaning then
intended.
- Program crashes
- Program runs forever
- Program gives answer but different then expected
Python programs
A program is sequence of definitions and commands.
- Definitions are evaluated
- Commands are executed by python interpreter by shell
Commands (statements) instruct interpreter to do something.
These can be typed directly in a shell or stored in a file that is read into the shell and
evaluated.
Objects
Programs manipulate data objects.
Object have a type that define things programs can do to them
◦ Ana is a human so she can walk, speak English, etc.
Objects can be scalar or non scalar
Scalar objects:
String = “Hello” -> words ()
Integer = 256 -> hele nummers ()
Float = 8.5 -> komma getallen ()
List = [1,2,3,4,] -> een lijst aan strings, integers, floats etc. [ ] (tuple is same but with ( ) )
Dictionary = { “a” = “apple”, “b” = “banana”} { }
Boolean = TRUE, FALSE
Non type = Special and has one value, None
Can convert object of one type to another
Float(3) converts integer 3 to float 3.0
Int(3.9) truncates float 3.9 to integer 3
Use print( ) to print something.
Expressions
- Combine objects and operators to form expressions.
- An expression has a value, which has a type.
- Simple expression: <object <operator> <object>
Pagina 3 van 83
, Simple operations
Radius = Radius + 1 == Radius +=1
On the left is the variable name, on the right are equivalent to a value.
Binding variables and values
Abstracting expressions
We give names to value of expression, this is so we can reuse the names instead of the values.
This makes it easier to change the codes in a later stadium in it will provide a clean code.
Pagina 4 van 83
Voordelen van het kopen van samenvattingen bij Stuvia op een rij:
Verzekerd van kwaliteit door reviews
Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!
Snel en makkelijk kopen
Je betaalt supersnel en eenmalig met iDeal, creditcard of Stuvia-tegoed voor de samenvatting. Zonder lidmaatschap.
Focus op de essentie
Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!
Veelgestelde vragen
Wat krijg ik als ik dit document koop?
Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.
Tevredenheidsgarantie: hoe werkt dat?
Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.
Van wie koop ik deze samenvatting?
Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper joannavoortman. Stuvia faciliteert de betaling aan de verkoper.
Zit ik meteen vast aan een abonnement?
Nee, je koopt alleen deze samenvatting voor €7,49. Je zit daarna nergens aan vast.