Algorithms and Datastructures in Python (6012B0414Y)
Institution
Universiteit Van Amsterdam (UvA)
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.
Algorithms and Datastructures in Python (6012B0414Y)
All documents for this subject (1)
2
reviews
By: arnoldmiklospap • 2 year ago
By: davidnelck • 5 year ago
Seller
Follow
joannavoortman
Reviews received
Content preview
Lecture 1:
You got 2 types of knowledge:
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
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller joannavoortman. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $8.15. You're not tied to anything after your purchase.