RFNXVfwQQPS4J

Number guessing game

Source: licencja: CC 0.

Zabawa w zgadywanie liczby

You will learn
  • how to create a program using random numbers,

  • to apply conditional and sequential instructions.

RcI9Sbi58mpXu1
nagranie abstraktu

Children often play in guessing. One of the games is guessing the number or objects that the other person has in mind.

Your task is to write a script in which the computer „invents” a number, and you guess it. The rules are simple – determine the range of numbers between which the number is looked for. If the number you choose is too small or too large, you enter the next one. The game lasts so long until you guess the number.

Before writing a script, ask the other person to play the game together. Write down your answers and discuss what would be important for the algorithm of your script.

RTjMcMbLMQ3KF1
nagranie abstraktu

Before you start writing a script, learn how to communicate with the sprite. Blocks from the Sensing and Operators category are helpful in communication.

Task 1
R1WutILQ43M1m1
nagranie abstraktu

Build a script in which the sprite will ask you for your name and then use it to greet you.

R1YpvtuV7LaCi1
nagranie abstraktu

One of the conditions of the game in guessing numbers is choosing any number by the program. For this purpose, it draws numbers in the range given to him. The randomrandomrandom operator pick random ... to ... is useful here. In addition to this, you will need a variablevariablevariable to which you will assign the drawn number.

Task 2
R1cR3ylZFlokW1
nagranie abstraktu

Build a script in which the program draws a number from 1 to 20. The drawn number has to be shown on the screen. The sprite says if the number is smaller or greater than 10.

Then change the script so that the upper boundupper boundupper bound of the draw numbers depends on your choice.

You can compare your solutionsolutionsolution with the one on the slideshow. It shows how to test the program.

RCpzVyP8uEaDy1
Pokaz zawiera zrzuty ekranu z programu Scratch przestawiające przypisywanie wartości losowych. Instrukcja obsługi z poziomu klawiatury: 1. Uruchomienie aplikacji - ENTER, 2. Na każdym ze slajdów czytany jest automatycznie tekst alternatywny po polsku, 3. Przy pierwszym uruchomieniu na pierwszym slajdzie, czytanie tekstu po angielsku - TAB, 4. Przejście między slajdami: do następnego slajdu - TAB, do poprzedniego slajdu - TAB + SHIFT, 5. Przejście do czytania napisu po angielsku - strzałka w górę + strzałka w dół (czyta tekst po angielsku widoczny na slajdzie).
Source: GroMar, licencja: CC BY 3.0.
Task 3
ROk34u8LzK1w11
nagranie abstraktu

Using your previous scripts, build a script to play the game of guessing numbers. Add selected backdrop. You can add a countercountercounter of correct answers or scored pointsscored pointsscored points.

R1SsuB52HXkwe1
nagranie abstraktu

A useful function of the program is to draw numbers from the selected range.

Exercises

R10wHeuZJDVXU
Exercise 1
Wersja alternatywna ćwiczenia: Which sentence is true? Możliwe odpowiedzi: 1. You cannot use more than one variable in one script., 2. Variables can be used to remember the drawn number., 3. Variables are shown by default on the screen, but you can also hide them., 4. The algorithm is the actions that we perform in order to perform a specific task.
Exercise 2

Expand your script for guessing numbers so that the numbers you use appear on the screen.

Exercise 3

Describe in English how to build a script that draws a number from the selected range.

Exercise 4
ReLUQ95GXsIyk
Wersja alternatywna ćwiczenia: Indicate which pairs of expressions or words are translated correctly. Możliwe odpowiedzi: 1. zmienna - variable, 2. przypadkowy - random, 3. rozwiązanie - solution, 4. licznik - counter, 5. dolna granica - upper bound, 6. górna granica - lower bound
zadanie
Source: GroMar, licencja: CC BY 3.0.
RNqIqwpP4Qa671
Interaktywna gra, polegająca na łączeniu wyrazów w pary w ciągu jednej minuty. Czas zaczyna upływać wraz z rozpoczęciem gry. Jeden ruch to odkrywanie najpierw jednej potem drugiej karty z wyrazem. Każdy wyraz jest odczytywany. Kolejny ruch to odkrywanie trzeciej i czwartej karty. W ten sposób odsłuchasz wszystkie wyrazy. Nawigacja z poziomu klawiatury za pomocą strzałek, odsłuchiwanie wyrazów enterem lub spacją. Znajdź wszystkie pary wyrazów.
Source: Zespół autorski Politechniki Łódzkiej, licencja: CC BY 3.0.

Glossary

counter
counter

licznik

R9yYBwIPtR1FE1
wymowa w języku angielskim: counter
lower bound
lower bound

dolna granica

R1N5cZYsy2qwV1
wymowa w języku angielskim: lower bound
random
random

losowy

R1Yb7IuqnalFb1
wymowa w języku angielskim: random
scored points
scored points

zdobyte punkty

R1JtACwZFnfSH1
wymowa w języku angielskim: scored points
solution
solution

rozwiązanie

R11VE1rupjfSa1
wymowa w języku angielskim: solution
upper bound
upper bound

górna granica

R18F1n1SJzLSr1
wymowa w języku angielskim: upper bound
variable
variable

zmienna 

RCBeE3UIqQDMk1
wymowa w języku angielskim: variable

Keywords

lower boundlower boundlower bound

randomrandomrandom

upper boundupper boundupper bound

variablevariablevariable