Variables and Data types
Create your own Program
Set your Learning Objectives to red.
We are going to save all of our work for this topic into a PowerPoint like we did in our assessment.
Save your PowerPoint as 'Programming 1'
You have two python options for completing todays lesson.
In class we are going to be using the Python tool called 'Thonny' if you are at home you can also download it by clicking on the image below
If for any reason you cannot download Thonny then click on the link below to use an online version of Python called CodeSkulptor3. Just be aware that the lessons are based upon using python in Thonny however the code will be exactly the same.
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.
Add the following lines of code to your 'hello world' program
print(“Hello \n World” )
print(“Hello” + “World” )
Explain your answers in your Powerpoint next to a screenshot of your code
("This is a very very very\
very very very very very very\
very very very long line")
("This is a very very very\n\
very very very very very very\n\
very very very long line")
("""This is a very very very
very very very very very very
very very very long line""")
("8" + "3")
Sometimes when your program does not work it is often the case that you have made a syntax error. Syntax errors are typographical mistakes that the programmer has made. When the code get translated for the computer to understand you will get an error message. Sometimes the message is useful, sometimes it is not!
When you are writing programs especially as they get more complex it is very difficult to not to make syntax errors (i do it all the time), so it is good to be able to understand the error messages so you can fix it yourself. As you get more experienced you will learn to interpret the error messages more easily and quickly.
Copy the code below into a new python file and save it as "debugging"
Try and fix all the errors so that the code works
print("This is a poem")
print(Once there was a little boy,)
print(With curly hair and pleasant eye—")
Print("A boy who always told the truth,")
print(And never, never told a lie.")
Print("And when he trotted off to school,")
pint("The children all about would cry,")
PRINT("There goes the curly-headed boy—")
print(The "boy that never tells a lie.")
Add #comments at the end of each line where there is an error, stating what type of error it was.
Lets look at the learning outcomes and decide which one best describes our current level of understanding :
Tick the one you feel is closest to your level