What Is Code?
Code is a set of step-by-step commands written for a computer.
Computers don’t “think”... they simply follow instructions exactly in the order they are given.
A program might contain just a few lines of code, or it might contain thousands. Large games and apps can contain millions of lines. But no matter how big a program is, it still works the same way: one instruction at a time.
One of the most common things programs do is calculate. Addition is used constantly in software... especially in games (health, scores, damage, money, experience points).
Computers don’t “think”... they simply follow instructions exactly in the order they are given.
A program might contain just a few lines of code, or it might contain thousands. Large games and apps can contain millions of lines. But no matter how big a program is, it still works the same way: one instruction at a time.
One of the most common things programs do is calculate. Addition is used constantly in software... especially in games (health, scores, damage, money, experience points).
Displaying Output in Python
In Python, we use the
To display words (text), we use quotation marks:
In Python, we use the
print() function to show something on the screen.
To display words (text), we use quotation marks:
print("Hello world")
To display a number, we don’t need quotation marks:
print(5)Python can also solve maths inside the brackets before printing:
print(5 + 3)First, Python works out the answer. Then, it displays the result.
Assignment:
Our hero's axe normally does 100 damage.
When enchanted, it does an extra 50 damage.
Write Python code that calculates and prints: 100 + 50
Our hero's axe normally does 100 damage.
When enchanted, it does an extra 50 damage.
Write Python code that calculates and prints: 100 + 50
Write your solution below
# Write your code below