Presentation is loading. Please wait.

Presentation is loading. Please wait.

Inputs, Outputs and Assignment

Similar presentations


Presentation on theme: "Inputs, Outputs and Assignment"— Presentation transcript:

1 Inputs, Outputs and Assignment
Keywords Input, Output, Assignment, Pseudocode, Flowchart, Identifier, Variable, Constant Concatenation, Memory locations, Parameters Variables Inputs, Outputs and Assignment

2 What is a variable? What is assignment? Objectives INPUT Name
BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. Computer programs accept inputs from a user, processes them using some constants and outputs back to the user. It is a good idea to label various inputs, constants and outputs with descriptive names (the process known as assignment). None of them should start with a number or contain spaces. Phrase = “I like you ”+ Name INPUT Name OUTPUT Phrase What is assignment? Starter activity During assignment, information is stored in memory locations under descriptive names called “identifiers”. A memory location where information relevant to the program running is stored is called: - “a variable” if it changes throughout the program or - “a constant” if it is fixed for the duration of the program.

3 BIG PICTURE Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. Variables are like building blocks or containers from which we build up our programs. Like blocks in Tetris, variables come in different types, like different containers for different purposes in real life: - a milk jug looks different from a petrol can - liquids are stored differently from solids. Starter activity

4 Memory Locations Objectives
BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. Any information that a program makes use of, e.g. user's age, is stored in RAM while the program runs. RAM is divided in memory locations with long hexadecimal (but really binary) addresses. Here, we use Python to find out the addresses hiding behind the labels "a" and "b" that we gave them to store values 6 and 8, respectively. Starter activity

5 Coding vs Spreadsheets
Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. We have renamed our variables from the spreadsheet style to the one more common on programming. Starter activity Why did we rename A1 and B1 to first_num and second_num?

6 Pseudocode vs Flowcharts
Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. START SPACE = “ “ INPUT Name Phrase = “Hello” + SPACE + Name OUTPUT Phrase END Starter activity

7 Constants Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. In the previous program one of the labels (SPACE) was in capital letters. This refers to memory locations that hold CONSTANT values. Constants are values that don’t change as the program runs. Here is another well-known constant: Starter activity

8 Output Computers are general-purpose problem solving machines.
Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. Computers are general-purpose problem solving machines. Just like most machines, they need raw materials, known as inputs, time and instructions to process the inputs the results, known as outputs. Example of output: Starter activity A program stores a message that it wants to display to user.

9 Inputs Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. Without inputs, our programs are not very useful as they can’t interact with the outside world and always produce the same result. We are going to create a program that asks user to input their name and then greets them by concatenating (joining) their name with a greeting. Inputs come from the console, from a file, or from elsewhere in a modular program – are known as “parameters”. Starter activity

10 Inputs and assignments
Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. In most programming languages, inputs come as text. “1234” is still text, until you need to use it in calculation – at which point it needs to be converted to a number. Once the data is input into the program, we often need to store it. We store data by “assigning” it to a memory location with a descriptive label, known as a “variable”. INPUT UserName INCREMENT attempts UserName recognized? YES INPUT Pwd NO OUTPUT “Try again” Starter activity

11 Problem Solving Objectives
BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. In Physics, we can look at an object falling from rest. The formula for its velocity after a time of t seconds is v = g * t where g is the acceleration of gravity. The value for g on planet Earth is 9.8 m/s2 . A. What is the velocity of a tennis ball after 5 seconds of falling? Starter activity

12 Variables and Constants
Objectives BEGINNER: Explain input, assignment and outputs within programming. ADVANCED: Identify variables and constants in programs. EXPERT: Develop programs to solve problems that use constants, variables, inputs, assignment and outputs. In the example program we used capital letter G for gravity acceleration. We use CAPITAL letters for CONSTANTS – values that don’t change between the program runs (they remain, “constant”). Marking constants in capitals simplifies debugging (constants are less likely to generate mistakes as they don’t change during runtime) and is good industry practice. Starter activity VARIABLE CONSTANT


Download ppt "Inputs, Outputs and Assignment"

Similar presentations


Ads by Google