Task 1
Explain what the following pseudocode does
1 name <- "Axl"
2 OUTPUT name
Extra question - why isn't name in speech marks on line 2?
Task 2
Concatenation. You can combine variables with strings in an output
1 name1 <- "Axl"
2 name2 <- "Slash"
Add 2 more variables to store 'Duff' and 'Izzy'
The following line uses concatenation to join the variables together with the string 'and' to make a sentence.
Complete the line to output all of the variables
OUTPUT name1, " and ", name2, " and "......................................
Task 3
Assign your name and your favourite food to 2 separate variables with suitable names.
SIMPLE
Output the contents of the variables on 2 separate lines
MEDIUM
Output two sentences (not just the contents of the variables). The first with your name, the second with your favourite food.
COMPLEX
Output both pieces of information as part of the same sentence.
Make sure that you have spaces and punctuation in the correct places.
Task 4
4.1 - Predict what will happen when the following algorithm is executed.
OUTPUT "Hi! What's your name?"
name <- "Odaly"
OUTPUT "Hi ", name, "! How are you today?"
How many variables are there? .........................
What are the names of the variables? ........................
What does the program output? ........................
4.2 - Adapt the pseudocode above so that it allows you to input your name and assigns it to the name variable.
4.3 - The last line of the following algorithm must include both the name and the answer variables. Add the last line.
name <- "Billy"
OUTPUT "We want to know if you like programming!"
OUTPUT "Do you like programming ", name, "?"
INPUT answer
.....................................................................
What will be the output (what will you see on screen) of the above algorithm?
Task 5
What is the output on lines 7, 8 and 12?
1 name1 <- "Ross"
2 name2 <- "Monica"
3 name3 <- "Joey"
4 name4 <- "Rachel"
5 name5 <- "Chandler"
6
7 OUTPUT name1, " and ", name4 //The output is: .............................
8 OUTPUT name3 //The output is: ...............................
9
10 name3 <- "Phoebe"
11
12 OUTPUT name3 // the output is: .................................
Task 6
INPUT name
OUTPUT "We want to know if you like programming!"
OUTPUT "Do you like programming ", name, "?"
INPUT answer
.....................................................................
Task 7
Lots of websites use chatbots to interact with their customers. These chatbots are often very sophisticated and use AI to learn and adapt to the user. Our chat bot is going to be a bit simpler.
The chatbot should work like this:
•Ask the user their name and store it in a variable.
•Greet the user by name.
•Ask the user three questions about themselves and store their responses in three different suitably named variables.
•Respond to each of the questions one by one, using the user’s name in the response.
•Output a summary of all of the user’s answers in a single sentence.