Vous êtes sur la page 1sur 9

Algorithm

• It is effective, which means that an answer is found and it


finishes, that is it has a finite number of steps.

• We can think of an algorithm as a set of instructions which


we must follow in order to complete a task successfully.

• An example is a recipe that we must follow when baking a


cake.
Algorithms & Problem Solving
• Problem Solving Process
•Clear understanding • There may be many possible
Analyse •What constitutes a solution
Problem solutions
• There may be many possible ways
•What are the datatypes?
•How is the data structured?
of representing the data in our
Describe Data
& Algorithms •Create appropriate algorithms program
• There are different types of
•Represent data algorithmic approaches that can
Implement
Program
•Implement algorithms be taken depending on the
problem at hand
•Create test cases
• BUGS will exist – they can be
Test & Debug
•Fix any bugs difficult to eradicate!

17/09/2018 Programming for BIG Data 2


Big Data
• Gartner’s Doug Laney published report in 2001 stating the 3 V’s for Big Data
• High Volume
• High Velocity
• High Variety

• Based on the concept of Doug Mashey from Silicon Graphics in the mid-90s
Variables & Identifiers
• Keyword Identifiers

• A keyword identifier has a pre-defined meaning in a programming language


Python 2.75 has
31 keywords

17/09/2018 Programming for BIG Data 4


2.3 Variables & Identifiers
• Other Identifiers

• Python also has some other predefined identifiers that can be used as variable name
identifiers but should not be!!
• print
• exit
• quit
• float
• int

• The opposite command examples


illustrate how to check if an
identifier is a
predefined identifier in Python

17/09/2018 Programming for BIG Data 5


Operators
Operator Description Example Result
+ Addition 2 + 3 5
- Subtration (binary 3 - 2 1
operator)

- Negation (unary -3 -3
operator)

* Multiplication 7*5 35
/ Division 5/3 1
% Modulus 34 % 2 0
// Truncated Division 6//4.0 1.0
** Exponentiation 2**3 8

The result of truncated division will depend on the datatypes of


the operands. The resultant value will be a whole number
equivalent represented as either an integer or a float.

17/09/2018 Programming for BIG Data 6


Input & Raw Input
• input(“Enter a number?”)

• amount = raw_input(“Please enter an amount?”)


• cent_amount = amount * 100
• print(cent_amount)
Practice, Practice, Practice
• Write a Python Program that transforms EUR in EURCENT. The
amount of EUR is given as input and the amount of EUROCENTs is
printed as output.

• E.g., if the program will take as input 1 EUR will give as output 100 EURCENTs
• E.g., if the program will take as input 5 EUR will give as output 500 EURCENTs
Summary
• Algorithm
• Algorithms & Problem Solving
• Big Data
• Variables & Identifiers
• Operators
• Input & Raw Input
• Practice

Vous aimerez peut-être aussi