Sie sind auf Seite 1von 8

Programming in

ython

Name:

Use this booklet to summarise what you have learnt each week.

Week 1
Two modes are available to programmer if they want to enter Python code.

mode

These are known as


____________________

mode

Today, you will have learnt about using the print() statement. If a new programmer
was starting out to learn Python, give three pieces of advice you would offer:
1)
2)
3)
Which of the following 3 statements is correct?
(i)
(ii)

PRINT(Welcome to Dalriada)
print(Welcome to Dalriada)

(iii)

print(Welcome to Dalriada)

Week 2
(i)

What is a variable?

(ii)

How many variables can you spot in the program below?

print(Welcome to Dalriada)
aName = input()
print(Nice to meet you)
anAge = input()
(iii)

What are the names of the variables you spotted?

Assignment means to put into. So, to assign data to a variable

Variable_Name

Assignment

Data

means, to put data into a variable.


In python, the assignment arrow is not used. Instead, python uses the
(iv)

sign.

Show how to assign the following values to the following variables in Python.
a. Assign the value 45 to a variable called aNumber.

b. Assign the letter K to a variable called aCharacter.

c. Assign the phrase Whats up?to a variable called Greeting.


3

Week 3
(i)

Complete the table


Mathematical Operator

Python Syntax

Addition

Subtraction
Division
Multiplication

(ii)

Coders (or programmers) find it very useful to enter comments throughout


their code. What is a comment and give one example of how you could add a
comment to the program below.

print("Please type your name in")


my_name = input ()
print(Nice to meet you ,my_name)

(iii)

Can you spot the three mistakes in the program below?

Print(Welcome to Dalriada)
aName = input
print(Nice to meet you aName)
4

Week 4
(i)

In Python, the double-equal sign is used to indicate equality.


Complete the table below, using the first example to help you.
Assignment =

First statement

Or

Second Phrase

Equal to == ?

(ii)

==

aName

Mary

aMonth

January

100

100

Look at the following statement written in standard English.


If aName is equal to David then Output Hello David Else Output Hello User.
What would this look like if this was to be turned into python program code?
(Enter your if statement below in Python coderemembering to follow the
rules your teacher has shown you).

(iii)

Give 2 important bits of advice to remember when using if statements in


Python.

Week 5
Look at the code below:

print("What is 2 + 2?")
answer = input ()
(i)

What does the second line mean?

If this program was to be improved, we could do the following:

print("What is 2 + 2?")
answer = input ()
answer = int(answer)
(ii)

Explain the purpose in line 3 above?

Look at the program below:

score = 0
print("What is 2 + 2?")
answer = input ()
answer = int(answer)
if answer == 4:
print("Well done")
score = score + 1
else:
print("Sorry the answer was 4")
(iii)

Explain why the line score = score + 1 has been inserted?

Week 6
Look at the following statements below:
If score > 80 then Output Grade A.
If score > 70 then Output Grade B.
If score > 60 then Output Grade C ELSE Output Grade D.
(i)

What would the above instructions look like in Python? Write your Python
code below:

(ii)

You have learnt lots of syntax rules when coding in Python. Can you think of
5 pieces of advice you could give to a new programmer who is learning to
code in Python? List them below:
a.

b.

c.

d.

e.

Das könnte Ihnen auch gefallen