- Oct 2018
-
runestone.academy runestone.academy
-
Python math module
Prepare example of using math modul! secondprogram.py A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended.
-
Computer science
Edsger Dijkstra:
Computer science is no more about computers than astronomy is about telescopes.
-
-
runestone.academy runestone.academy
-
abstraction
Abstraction is an important paradigm for solving complex problems.
-
- Oct 2017
-
runestone.academy runestone.academy
-
Whenever we want to implement an abstract data type, we will do so with a new class.
Typical example is an abstract data type stack.
-
-
runestone.academy runestone.academy
-
while counter <= 10 and not done:
This while loop finishes if counter > 10 or done equals True.
-
algorithms require two important control structures: iteration and selection
Python provides loop and conditional statements.
Loop sttements:
- while loop
- for loop
Conditional statements:
- if statement
- ifelse statement
-
-
runestone.academy runestone.academy
-
len
len is a metod.
-
lists are considered to be sequentially ordered
Lists are naturally ordered by adding and removing elements.
-
integer division
Relation between operator // and %.
a = (a // b) * b + a % b
-
Assignment statements provide a way to associate a name with a value
Variable = Expression
An Expression is evaluated and the it's value (reference to an object) is assigned to a Variable
-
called __add__ in Python
The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y.
-
len
len(s) is built-in function
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).
-
Collection
Collection is an object that contains other objects.
-
Python supports the object-oriented programming paradigm
The main OOP concepts:
- an object as a model of a real object
- a class as a factory for objects or as a template that defines the structure of objects from this class and behavior of objects from this class
- an object as an instance of a class
- a method with or without parameters describes the behavior of instances
- calling or invoking method
-
The return value is None.
-
-
runestone.academy runestone.academy
-
new to Python
For newbies I can recommend video lectures by Charles Severence.
-
-
runestone.academy runestone.academy
-
algorithms require constructs that perform sequential processing, selection for decision-making, and iteration for repetitive contro
Programming languages provide control structures for sequential, conditional and iterative performing partial actions.
-
data types
Data type = set of values + set of operations.
Data types are glasses for interpretation of binary data.
-
Programming is the process of taking an algorithm and encoding it into a notation, a programming language, so that it can be executed by a computer
This is programming in the narrow sense of the word. Programming in a broader sense contains also analysis of the problem, design the solution, testing, debugging, maintaining.
-
Algorithms describe the solution to a problem in terms of the data needed to represent the problem instance and the set of steps necessary to produce the intended result
Algorithm is a transformation of valid input data to corresponding otput data.
Features of a good algorithms:
Precision– the steps are precisely stated(defined).
Uniqueness– results of each step are uniquely defined and only depend on the input and the result of the preceding steps.
Finiteness– the algorithm stops after a finite number of instructions are executed.
Input– the algorithm receives input.
Output– the algorithm produces output.
Generality– the algorithm applies to a set of inputs.
-
-
runestone.academy runestone.academy
-
two important areas
- The study of algorithms and data structures makes you better algorithmic problem solver.
- For algorithms implementation is used Python programming language. Review this language is not exhaustive. For more details I refer you to the parallel course Python Basics.
-
-
runestone.academy runestone.academy
-
seeing how different algorithms are designed helps us to take on the next challenging problem that we are given.
There are general design techniques (strategies) for solving algorithmic problem:
- Brute Force
- Backtracking
- Greedy approach
- Dynamic Programming
- Divide and Conquer
-
-
runestone.academy runestone.academy
-
By creating models of the problem domain
Object oriented programming is based on creating models of the problem domain.
-
-
runestone.academy runestone.academy
-
Python
Python is object oriented language that is used in this course for algorithms implementation.
-
abstract data type
Abstract data type defines the actions that can be done with data without implementations. E.g. stack
-
- Sep 2017
-
runestone.academy runestone.academy
-
iteration and selection
Iteration, selection and sequence are three important control structures.
-