SlideShare a Scribd company logo
Introduction to programming
Class 2
Paul Brebner
A current “large” computer
• Remember Colossus? Early, big, expensive,
programmable, but special purpose (code
breaking) computer?
• D-Wave, also a big, expensive programmable
special purpose (optimisation) computer
– http://www.dwavesys.com/
$20M, = to 10th ranked supercomputer
supercooled, only a few in use
Finds best solution “instantly”
• Processing with D-Wave
– A lattice of 512 tiny superconducting circuits, known as qubits, is
chilled close to absolute zero to get quantum effects
– A user models a problem into a search for the “lowest point in a
vast landscape”
– The processor considers all possibilities simultaneously to
determine the lowest energy required to form those
relationships
– Multiple solutions are returned to the user, scaled to show
optimal answers
• What will things be like in 50 years time? A quantum
computer in your pocket.
Travelling Sales Person problem
• Visit every city only once, with shortest path
– Very hard to solve, and gets harder > cities
– Fastest supercomputer = 30 minutes
– D-Wave = ½ second
Revision
• How far did you get with the Exercises from
Class 1?
• Process “Exhibition” examples
– A few more
• http://processing.org/exhibition/works/starnursery/ind
ex_link.html (Needs Quicktime) Software for the R.E.M.
video Animal (youtube, screenshot next slide)
• http://processing.org/exhibition/works/yellowtail/inde
x_link.html
Your favourites?
• ???
Processing progress
• Activity 2
– Can you find your way around Processing
Environment ok? Examples? Reference? Tutorial?
– Running programs?
– Statements and comments
– Setup() and draw()
– Variables
– Basic/primitive data types
– Any questions?
Statements and Comments.
• Statements are the elements that make up programs. The ";" (semi-colon)
symbol is used to end statements. It is called the "statement terminator."
• Comments are used for making notes to help people better understand
programs. A comment begins with two forward slashes ("//").
• // The size function is a statement that tells the computer // how large to make
the window.
// Each function statement has zero or more parameters.
// Parameters are data passed into the function
// and are used as values for telling the computer what to do.
size(640, 360);
// The background function is a statement that tells the computer
// which color (or gray value) to make the background of the display window
background(204, 153, 0);
Variables
• A named place to store something – what?
– The Type of the thing.
• Syntax
type name; // undefined initial value
type name = value; // assign an initial value.
Note that “=“ means “put the value into the name” (not
equals which is “==“)!
• Examples
int numberOfPizzas = 12; // int are 32 bit integers
boolean iLikePizza = true; // boolean is true or false (maybe)
char theFirstLetterOfTheAlphabet = ‘a’; // “not a String”
float howMuchOfThePizzaIGot = 0.3333333; // 32bit decimal
Variables (contd)
• You must assign a value to a variable before you use it
int pizzasIHave; // no value
int pizzasYouHave = pizzasIHave – 3; // error
• You must declare a variable before you try and use it
(mostly)
int pizzasYouHave = pizzasIHave – 3; // error
int pizzasIHave = 99;
height and width are pre-declared system variables for
screen height and width (see Reference/Environment)
• You can’t declare the same variable more than once
(mostly)
int pizzasIHave = 99;
int pizzasIHave = 100; // error
Using variables
• Use wherever a non-variable can be used e.g.
int pizzasIHave = 99;
int pizzasYouHave;
pizzasYouHave = pizzasIHave – 0;
pizzasIHave = 100;
pizzasYouHave = pizzasIHave – 99;
• Can only assign variables/values of the correct Type
(mostly) – they don’t “fit”!
int pizzasIHave = ‘x’; // error
int pizzasIHave = 99.0; // error
int pizzasIHave = true; // error
float howMuchOfThePizzaIGot = 1; // is 0K, type cast to 1.0
Processing progress
• Activity 2 part 3
– Did you manage to install Processing environment?
School? Home?
– How far did you get with Tutorials 1 & 2?
• We will using selected parts of a Processing text
book:
– Getting Started with Processing, by Reas and Fry
– This course was based on Processing V2.
– Note: This is available as an ebook:
– http://shop.oreilly.com/product/0636920031406.do
PAGE 9
Example 2-1: Draw an Ellipse
In the editor, type the following:
ellipse(50, 50, 80, 80);
This line of code means “draw an ellipse, with the center 50 pixels over
from the left and 50 pixels down from the top, with a width and height of
80 pixels.” Click the Run button.
If you’ve typed everything correctly, you’ll see the ellipse image above. If
you didn’t type it correctly, the Message Area will turn red and complain
about an error. If this happens, make sure that you’ve copied the example
code exactly: the numbers should be contained within parentheses
and have commas between each of them, and the line should end with a
semicolon.
One of the most difficult things about getting started with programming
is that you have to be very specific about the syntax. The Processing
software isn’t always smart enough to know what you mean, and can be
quite fussy about the placement of punctuation. You’ll get used to it with a
little practice.
ellipse(50, 50, 80, 80);
This line of code means ... Oh, I’ve forgotten already.
Remembering what the parameters mean and the order may be hard?
Easier to declare some variables and use them?
int positionAcross = 50; // x pos
int positionDown = 50; // y pos
int ellipseWidth = 80;
int ellipseHeight = 80;
ellipse(positionCenter, positionDown, ellipseWidth, ellipseHeight);
More programming examples
• PAGE 10 Ex 2.2
– Add 2 variables for white (255) and black (0).
– Where do mouseX and mouseY come from?
– You can make special variables called CONSTANTS than can only be assigned to once and never
change their value
• final int WHITE = 255;
• final int BLACK = 0;
• final int GREY = WHITE/2;
• Try changing their value after first assignment...?
• E.g. WHITE = BLACK; // ???
• PAGE 14 top, right-click on orange text in editor and get help!
• Chapter 3 Draw
– X and y coordinates
– Functions and parameters
• Page 16 Ex 3.1
– size()
• Page 16 Ex 3.2
– point()
– Use the height and width system variables if you like
More programming examples
• Basic shapes
– Do up to Ex 3.7
• Drawing order Page 22 Ex 3.9-3.13
– Processing programs executed in order
– Shapes drawn later are drawn over the top of earlier shapes
• Colour (Page 26)
– Gray scales (white = 255, black = 0)
– Ex 3.14, Ex 3.15
– Page 28 Ex 3.16 Colour (RGB) Additive colour model see next slide
• What’s the difference between fill(255) and fill(255, 255, 255)?
– Try the colour selector
• What’s pure red? Pure green? Pure blue? How do you get orange? Yellow? Purple?
• Color is a Type in Processing (remember it was invented by Americans so NOT COLOUR)
– color orange = color(255, 132, 0);
– fill(orange);
• Try making some fruit and vegetable color variables and displaying them all on the screen
• E.g. Orange, tomato, apple, watermelon, grape, banana, etc.
– Ex 3.17 transparency
Can you draw a bowl? Hint: P. 20 arc() function
And for your next trick... (Next slide)
Giuseppe Arcimboldo an Italian painter best known for
portrait heads made entirely of such objects as fruits,
vegetables, flowers, fish, and books

More Related Content

Similar to Introduction to programming - class 2

Introduction to programming - class 3
Introduction to programming - class 3Introduction to programming - class 3
Introduction to programming - class 3
Paul Brebner
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
Amr Alaa El Deen
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
PedramKashiani
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
MIT,Imphal
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
pbarasia
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
 
PPS Unit-1.pdf
PPS Unit-1.pdfPPS Unit-1.pdf
PPS Unit-1.pdf
NenavathSurendhar
 
Class 12 CBSE Computer Science Investigatory Project
Class 12 CBSE Computer Science Investigatory ProjectClass 12 CBSE Computer Science Investigatory Project
Class 12 CBSE Computer Science Investigatory Project
NandanRamesh2
 
Software fundamentals
Software fundamentalsSoftware fundamentals
Software fundamentals
Susan Winters
 
c-programming
c-programmingc-programming
c-programming
Zulhazmi Harith
 
Distributed Computing & MapReduce
Distributed Computing & MapReduceDistributed Computing & MapReduce
Distributed Computing & MapReduce
coolmirza143
 
Cs1123 2 comp_prog
Cs1123 2 comp_progCs1123 2 comp_prog
Cs1123 2 comp_prog
TAlha MAlik
 
Ms vb
Ms vbMs vb
Ms vb
sirjade4
 
Introduction to programming - exercises 2
Introduction to programming - exercises 2Introduction to programming - exercises 2
Introduction to programming - exercises 2
Paul Brebner
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
TadiwaMawere
 
Python language data types
Python language data typesPython language data types
Python language data types
James Wong
 
Python language data types
Python language data typesPython language data types
Python language data types
Harry Potter
 
Python language data types
Python language data typesPython language data types
Python language data types
Hoang Nguyen
 
Python language data types
Python language data typesPython language data types
Python language data types
Young Alista
 

Similar to Introduction to programming - class 2 (20)

Introduction to programming - class 3
Introduction to programming - class 3Introduction to programming - class 3
Introduction to programming - class 3
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
PPS Unit-1.pdf
PPS Unit-1.pdfPPS Unit-1.pdf
PPS Unit-1.pdf
 
Class 12 CBSE Computer Science Investigatory Project
Class 12 CBSE Computer Science Investigatory ProjectClass 12 CBSE Computer Science Investigatory Project
Class 12 CBSE Computer Science Investigatory Project
 
Software fundamentals
Software fundamentalsSoftware fundamentals
Software fundamentals
 
c-programming
c-programmingc-programming
c-programming
 
Distributed Computing & MapReduce
Distributed Computing & MapReduceDistributed Computing & MapReduce
Distributed Computing & MapReduce
 
Cs1123 2 comp_prog
Cs1123 2 comp_progCs1123 2 comp_prog
Cs1123 2 comp_prog
 
Ms vb
Ms vbMs vb
Ms vb
 
Introduction to programming - exercises 2
Introduction to programming - exercises 2Introduction to programming - exercises 2
Introduction to programming - exercises 2
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 

More from Paul Brebner

The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
The Impact of Hardware and Software Version Changes on Apache Kafka Performan...The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
Paul Brebner
 
Apache ZooKeeper and Apache Curator: Meet the Dining Philosophers
Apache ZooKeeper and Apache Curator: Meet the Dining PhilosophersApache ZooKeeper and Apache Curator: Meet the Dining Philosophers
Apache ZooKeeper and Apache Curator: Meet the Dining Philosophers
Paul Brebner
 
Spinning your Drones with Cadence Workflows and Apache Kafka
Spinning your Drones with Cadence Workflows and Apache KafkaSpinning your Drones with Cadence Workflows and Apache Kafka
Spinning your Drones with Cadence Workflows and Apache Kafka
Paul Brebner
 
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Paul Brebner
 
Scaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/HardScaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/Hard
Paul Brebner
 
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/HardOPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
Paul Brebner
 
A Visual Introduction to Apache Kafka
A Visual Introduction to Apache KafkaA Visual Introduction to Apache Kafka
A Visual Introduction to Apache Kafka
Paul Brebner
 
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Paul Brebner
 
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
Paul Brebner
 
Grid Middleware – Principles, Practice and Potential
Grid Middleware – Principles, Practice and PotentialGrid Middleware – Principles, Practice and Potential
Grid Middleware – Principles, Practice and Potential
Paul Brebner
 
Grid middleware is easy to install, configure, secure, debug and manage acros...
Grid middleware is easy to install, configure, secure, debug and manage acros...Grid middleware is easy to install, configure, secure, debug and manage acros...
Grid middleware is easy to install, configure, secure, debug and manage acros...
Paul Brebner
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Paul Brebner
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Paul Brebner
 
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Paul Brebner
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Paul Brebner
 
0b101000 years of computing: a personal timeline - decade "0", the 1980's
0b101000 years of computing: a personal timeline - decade "0", the 1980's0b101000 years of computing: a personal timeline - decade "0", the 1980's
0b101000 years of computing: a personal timeline - decade "0", the 1980's
Paul Brebner
 
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
Paul Brebner
 
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
Paul Brebner
 
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
Paul Brebner
 
How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...
Paul Brebner
 

More from Paul Brebner (20)

The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
The Impact of Hardware and Software Version Changes on Apache Kafka Performan...The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
 
Apache ZooKeeper and Apache Curator: Meet the Dining Philosophers
Apache ZooKeeper and Apache Curator: Meet the Dining PhilosophersApache ZooKeeper and Apache Curator: Meet the Dining Philosophers
Apache ZooKeeper and Apache Curator: Meet the Dining Philosophers
 
Spinning your Drones with Cadence Workflows and Apache Kafka
Spinning your Drones with Cadence Workflows and Apache KafkaSpinning your Drones with Cadence Workflows and Apache Kafka
Spinning your Drones with Cadence Workflows and Apache Kafka
 
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
 
Scaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/HardScaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/Hard
 
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/HardOPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
 
A Visual Introduction to Apache Kafka
A Visual Introduction to Apache KafkaA Visual Introduction to Apache Kafka
A Visual Introduction to Apache Kafka
 
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
 
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
 
Grid Middleware – Principles, Practice and Potential
Grid Middleware – Principles, Practice and PotentialGrid Middleware – Principles, Practice and Potential
Grid Middleware – Principles, Practice and Potential
 
Grid middleware is easy to install, configure, secure, debug and manage acros...
Grid middleware is easy to install, configure, secure, debug and manage acros...Grid middleware is easy to install, configure, secure, debug and manage acros...
Grid middleware is easy to install, configure, secure, debug and manage acros...
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
 
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
 
0b101000 years of computing: a personal timeline - decade "0", the 1980's
0b101000 years of computing: a personal timeline - decade "0", the 1980's0b101000 years of computing: a personal timeline - decade "0", the 1980's
0b101000 years of computing: a personal timeline - decade "0", the 1980's
 
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
 
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
 
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
 
How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...
 

Recently uploaded

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 

Recently uploaded (20)

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 

Introduction to programming - class 2

  • 2. A current “large” computer • Remember Colossus? Early, big, expensive, programmable, but special purpose (code breaking) computer? • D-Wave, also a big, expensive programmable special purpose (optimisation) computer – http://www.dwavesys.com/
  • 3. $20M, = to 10th ranked supercomputer supercooled, only a few in use
  • 4. Finds best solution “instantly” • Processing with D-Wave – A lattice of 512 tiny superconducting circuits, known as qubits, is chilled close to absolute zero to get quantum effects – A user models a problem into a search for the “lowest point in a vast landscape” – The processor considers all possibilities simultaneously to determine the lowest energy required to form those relationships – Multiple solutions are returned to the user, scaled to show optimal answers • What will things be like in 50 years time? A quantum computer in your pocket.
  • 5. Travelling Sales Person problem • Visit every city only once, with shortest path – Very hard to solve, and gets harder > cities – Fastest supercomputer = 30 minutes – D-Wave = ½ second
  • 6. Revision • How far did you get with the Exercises from Class 1? • Process “Exhibition” examples – A few more • http://processing.org/exhibition/works/starnursery/ind ex_link.html (Needs Quicktime) Software for the R.E.M. video Animal (youtube, screenshot next slide) • http://processing.org/exhibition/works/yellowtail/inde x_link.html
  • 7.
  • 9. Processing progress • Activity 2 – Can you find your way around Processing Environment ok? Examples? Reference? Tutorial? – Running programs? – Statements and comments – Setup() and draw() – Variables – Basic/primitive data types – Any questions?
  • 10. Statements and Comments. • Statements are the elements that make up programs. The ";" (semi-colon) symbol is used to end statements. It is called the "statement terminator." • Comments are used for making notes to help people better understand programs. A comment begins with two forward slashes ("//"). • // The size function is a statement that tells the computer // how large to make the window. // Each function statement has zero or more parameters. // Parameters are data passed into the function // and are used as values for telling the computer what to do. size(640, 360); // The background function is a statement that tells the computer // which color (or gray value) to make the background of the display window background(204, 153, 0);
  • 11. Variables • A named place to store something – what? – The Type of the thing. • Syntax type name; // undefined initial value type name = value; // assign an initial value. Note that “=“ means “put the value into the name” (not equals which is “==“)! • Examples int numberOfPizzas = 12; // int are 32 bit integers boolean iLikePizza = true; // boolean is true or false (maybe) char theFirstLetterOfTheAlphabet = ‘a’; // “not a String” float howMuchOfThePizzaIGot = 0.3333333; // 32bit decimal
  • 12. Variables (contd) • You must assign a value to a variable before you use it int pizzasIHave; // no value int pizzasYouHave = pizzasIHave – 3; // error • You must declare a variable before you try and use it (mostly) int pizzasYouHave = pizzasIHave – 3; // error int pizzasIHave = 99; height and width are pre-declared system variables for screen height and width (see Reference/Environment) • You can’t declare the same variable more than once (mostly) int pizzasIHave = 99; int pizzasIHave = 100; // error
  • 13. Using variables • Use wherever a non-variable can be used e.g. int pizzasIHave = 99; int pizzasYouHave; pizzasYouHave = pizzasIHave – 0; pizzasIHave = 100; pizzasYouHave = pizzasIHave – 99; • Can only assign variables/values of the correct Type (mostly) – they don’t “fit”! int pizzasIHave = ‘x’; // error int pizzasIHave = 99.0; // error int pizzasIHave = true; // error float howMuchOfThePizzaIGot = 1; // is 0K, type cast to 1.0
  • 14. Processing progress • Activity 2 part 3 – Did you manage to install Processing environment? School? Home? – How far did you get with Tutorials 1 & 2? • We will using selected parts of a Processing text book: – Getting Started with Processing, by Reas and Fry – This course was based on Processing V2. – Note: This is available as an ebook: – http://shop.oreilly.com/product/0636920031406.do
  • 15.
  • 16. PAGE 9 Example 2-1: Draw an Ellipse In the editor, type the following: ellipse(50, 50, 80, 80); This line of code means “draw an ellipse, with the center 50 pixels over from the left and 50 pixels down from the top, with a width and height of 80 pixels.” Click the Run button. If you’ve typed everything correctly, you’ll see the ellipse image above. If you didn’t type it correctly, the Message Area will turn red and complain about an error. If this happens, make sure that you’ve copied the example code exactly: the numbers should be contained within parentheses and have commas between each of them, and the line should end with a semicolon. One of the most difficult things about getting started with programming is that you have to be very specific about the syntax. The Processing software isn’t always smart enough to know what you mean, and can be quite fussy about the placement of punctuation. You’ll get used to it with a little practice.
  • 17. ellipse(50, 50, 80, 80); This line of code means ... Oh, I’ve forgotten already. Remembering what the parameters mean and the order may be hard? Easier to declare some variables and use them? int positionAcross = 50; // x pos int positionDown = 50; // y pos int ellipseWidth = 80; int ellipseHeight = 80; ellipse(positionCenter, positionDown, ellipseWidth, ellipseHeight);
  • 18. More programming examples • PAGE 10 Ex 2.2 – Add 2 variables for white (255) and black (0). – Where do mouseX and mouseY come from? – You can make special variables called CONSTANTS than can only be assigned to once and never change their value • final int WHITE = 255; • final int BLACK = 0; • final int GREY = WHITE/2; • Try changing their value after first assignment...? • E.g. WHITE = BLACK; // ??? • PAGE 14 top, right-click on orange text in editor and get help! • Chapter 3 Draw – X and y coordinates – Functions and parameters • Page 16 Ex 3.1 – size() • Page 16 Ex 3.2 – point() – Use the height and width system variables if you like
  • 19. More programming examples • Basic shapes – Do up to Ex 3.7 • Drawing order Page 22 Ex 3.9-3.13 – Processing programs executed in order – Shapes drawn later are drawn over the top of earlier shapes • Colour (Page 26) – Gray scales (white = 255, black = 0) – Ex 3.14, Ex 3.15 – Page 28 Ex 3.16 Colour (RGB) Additive colour model see next slide • What’s the difference between fill(255) and fill(255, 255, 255)? – Try the colour selector • What’s pure red? Pure green? Pure blue? How do you get orange? Yellow? Purple? • Color is a Type in Processing (remember it was invented by Americans so NOT COLOUR) – color orange = color(255, 132, 0); – fill(orange); • Try making some fruit and vegetable color variables and displaying them all on the screen • E.g. Orange, tomato, apple, watermelon, grape, banana, etc. – Ex 3.17 transparency
  • 20.
  • 21. Can you draw a bowl? Hint: P. 20 arc() function And for your next trick... (Next slide)
  • 22. Giuseppe Arcimboldo an Italian painter best known for portrait heads made entirely of such objects as fruits, vegetables, flowers, fish, and books