Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE

## Lesson 1 - Intro to Coding

##### Learning Objectives
0 results forGuest
IDSkill_name
1 I can create a sequence - 'a set of steps to do something'
2 I can create a simple program in a computer language

## What is Coding?

Coding is writing computer code to create a program, to solve a problem. Programs are created to implement algorithms. Algorithms can be represented as pseudocode or a flowchart, and programming is the translation of these into a computer program

To tell a computer to do something, a program must be written to tell it exactly what to do and how to do it. If an algorithm has been designed, the computer program will follow this algorithm, step-by-step, which will tell the computer exactly what it should do.

• Python
• Java
• C++
• BASIC
• Scratch

## Computational Thinking

Computational thinking involves taking that complex problem and breaking it down into a series of small, more manageable problems (decomposition). Each of these smaller problems can then be looked at individually, considering how similar problems have been solved previously (pattern recognition) and focusing only on the important details, while ignoring irrelevant information (abstraction). Next, simple steps or rules to solve each of the smaller problems can be designed (algorithms).

## Breaking down the problem (Decomposition)

In computer science to solve a problem we first break it down into a series of parts or steps. we then try and put those parts into the correct or which we call 'Sequencing'. This is the specific order in which instructions are performed in an algorithm..

For example, a very simple algorithm for brushing teeth might consist of these steps:

1. put toothpaste on toothbrush
2. use toothbrush to clean teeth
3. rinse toothbrush

A toothbrush would still be used to clean the teeth and toothpaste would still be put on the brush. But because steps 1 and 2 are in the wrong sequence the teeth wouldn’t get cleaned with the toothpaste, and the toothpaste would be wasted.

A human would realise they had forgotten to add toothpaste at the start of the process, but a computer would not know that anything was wrong.

A computer can only do what it is programmed to do. If the steps are programmed in the wrong sequence, the computer will perform the tasks in this sequence – even if this is incorrect.

## Input - Output

In python we use built in functions to help us with our input and output. The function we use to output to the screen is print() and the function we use to get input from the keyboard is input().

Let us look at the the output method print() first.

### Task 1 - Hello World

#### Create a simple program that will output 'Hello World' to the screen

1. Type in PYTHON into your search bar.
2. Now select IDLE.
3. *This is called the Python 'Interpreter' or 'shell'

4. Now Type the following code into the shell window

### print ("Hello World")

5. Then press the 'enter' ↩ key

### Task 2 - Creating a real program

From the shell menu Select 'File' > 'New File'.

Now type in the same code as before

### print ("Hello World")

into the window and then select Run > Run Module (it will prompt you to save your file first - call your file name 'hello world')

## Challenges - Output

• ### 1

Say 'Hello World' instead of 'Hi'
Complete the challenge below

...In order to display text output in python you need to surround your message in quotation marks. The print function also needs your output to be surrounded with brackets.

print(" ")

• ### 2

New Line
Complete the challenge below

• ### 3

Another newline format
Complete the challenge below

...Any line of code that starts with a # is a comment: it doesn’t affect how the program runs, it’s just there to help explain what the code does.

• ### 4

Debugging
Complete the challenge below
• Hint - Check the brackets and quotation marks.

Your code won’t run at all until you’ve fixed all of the errors: You need to fix all the lines of code even before the first line will run.

Python is case sensitive: be careful with CAPITAL LETTERS and lowercase letters

• ### 5

Extension Challenge
Complete one or all of the extension challenges below