You are on page 1of 2

NCSS Challenge Introduction to

Programming using Python



Python words/syntax Programming Concepts
;
Semi-colon is added to the end of each line of
code
Syntax rules of the programming language
Print displays output on the screen
e.g.
print "Hello, Python!";
print counter; (prints the value of the
variable called counter)
Interpreter runs the program, checking for
errors
#
Allows the programmer to add a comment in the
code
Variable
- Holds a value while the program is running.
- Variable may be:
o String (has characters)
o Integer
o Decimal
input collects data from the user (e.g. user
enters their name)
Strings characters including letters and
numbers
+ (concatenation) adds a space before/after
the character
Integers
, (concatenation) does not include a space
before/after the character
Purple = Python words
Green = string
len counts all of the characters in a string

e.g.




Breaking the problem down
The first step in writing any program is to break
the problem down into small components. We
can break this task into these steps:
1. Read text from the user and obtain the
degrees Celsius figure that we need to
convert
2. Convert the text into an integer
3. Apply the conversion formula
4. Print the result back to the user
By tackling one step at a time the program is
much easier to write. Have a think about what
commands you will need before you read on.
int
If you want to use a string as a number you must
first convert it to one. You can convert a string to
an integer (a whole number) with
the int function.
Types of errors:
SyntaxError
NameError
ValueError
Doing maths
Python can do all the basic maths you would
expect. The main operators are:
operator operation
+ addition
- subtraction
* multiplication
/ division
** to the power of

You might also like