Lessons 31 · 1 lessons · D.T. Kamaltdinova, D.M. Sayfurov. Informatics and Information Technology, Grade 5 (general editor F.M. Zakirova). “Nashriyot uyi Tasvir”, Tashkent, 2020
31
Working with sound and text
Textbook: pp. 100–102
GoalBuild a simple conversation program in which a sprite asks a question, takes the user’s answer and makes a sound.
New words
ask ... and wait: the sprite asks and waits for the typed answer · so‘ra va kutanswer: the block that holds what the user typed · javobsay: shows a speech bubble · aytif ... then: runs blocks only when a condition is true · agar ... bo‘lsa
Explanation
In Scratch a sprite can talk with the user. For this we use “ask ... and wait” from Sensing: when the program runs, a typing box appears at the bottom of the stage and the user types the answer and presses Enter. The typed reply is held in the “answer” block. The “say” block from Looks shows words in a speech bubble. To combine several pieces of text use the “join” block from Operators: for example “Great choice: ” and the answer join into “Great choice: apple”. For sound the Sound category has “start sound” and “play sound until done”. The “if ... then” block runs its commands only when the condition is true, for example if the answer equals 5 it says “Correct!”. For safety: never type a password, home address or phone number into your project or someone else’s; let sprites ask only harmless questions such as a name or favourite colour.
Worked examples
A fruit program: green flag → ask “What is your favourite fruit?” and wait → say (join “Great choice: ” answer) for 2 seconds → start sound.
A maths game: ask “What is 2 + 3?” and wait → if answer = 5, say “Correct!”, otherwise say “Try again”.
Class activity
“Chat program”: pairs build a short conversation (2 questions, 2 answers) with a favourite sprite. Another pair tests it and finds mistakes or unclear spots.
Practice
1
Which block takes the user’s reply and in which category is it?
“Ask ... and wait”; in Sensing.
2
How do we join the text “Great choice: ” with the answer?
With the “join” block from Operators.
3
The program asks “What is 7 + 8?”. Which number must “answer” equal in the condition?
15
4
Why is it unsafe to make a sprite ask for a password or address?
Others may run the project; personal details typed in could end up with strangers.