Try it:
Below you’ll see some example python code that will output three things to the screen.
Press Ctrl + Enter to run the code.
Click on your score in the top right corner of the code editor to see what your code needs to do.
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.
Challenges:
- Change line 3 so it displays an ! after your name
You’ll need to surround the
!
with quotes ("!"
) and then add it on to the text to be displayed after the variablename
using+
Joining together text and / or variables is called concatenation. If text is surrounded with quotes (e.g.
"name"
) , it’ll use that text literally as you’ve written it.If text is not surrounded with quotes it will use that text as a variable name and try to find the value stored in that variable.
- Change line 7 so that it will say “chips? I love chips!” or “pizza? I love pizza!”
Be careful with quotation marks – you’ll need to use the food variable twice in this line of code.
- Change line 10 so that it will show your favourite word 100 times
At the moment, whatever you input as your favourite word will be displayed 10 times because
word * 10
multiplies (repeats) whatever is stored in theword
variable 10 times.
On the next page you’ll get some code examples that have been deliberately broken for you to try to fix.
KPRIDE
KPRIDE stands for Keywords, Predict, Run, Investigate, Debug and Extend and it’s a way of helping you explore and understand python code. Click on the image below for a set of KPRIDE activities for this python skill.
Page 1: Intro
Page 2: The theory: learn what you need to know as fast as possible.
Page 3: Try it: try out and adapt some working python code snippets.
Page 4: Debug it: Learn how to find and fix common mistakes.
Page 5: Extend it: Choose a project idea to use your newfound python skills.
please check chalenge one :
print(βHello β + name + β an!β )
(it still gives me an error!)
Replace the ” an!” with “!” and you should be OK π
need help with line 7 where do you put the second + food + ? in the line
Hello,
Try printing food + “? I love ” + food + “!”