ROUND, RANDOM and a trace · ROUND, RANDOM 및 추적
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
A shop rounds a price
ROUND(Value, Places)returnsValuerounded toPlacesdecimal places.Placesis an integer.ROUND(3.14159, 2)is3.14.ROUND(9.6, 0)is the whole number10.- The syllabus lists
ROUNDwithDIV,MODandRANDOM.
한국어
상점이 가격을 반올림합니다
- **
ROUND(Value, Places)**는 **Value**을 소수점Places자리까지 반올림하여 반환합니다. - **
Places**는 정수입니다. **ROUND(3.14159, 2)**은 **3.14**입니다. **ROUND(9.6, 0)**는 전체 숫자 **10**입니다. - 교재 과정(syllabus)은 **
ROUND**를DIV,MOD및 **RANDOM**과 함께 나열합니다.
OUTPUT ROUND(3.14159, 2)
OUTPUT ROUND(9.6, 0)
English
A dice uses RANDOM
RANDOM()returns a real from 0 to 1, including both ends. Each run can differ.- A board-game dice is
ROUND(RANDOM() * 6, 0). The paper uses it when the result may vary, so you are not asked for one fixed output.
한국어
주사위는 RANDOM을 사용합니다
- **
RANDOM()**는 0부터 1까지의 실수를 반환하며, 양 끝값을 포함합니다. 실행마다 결과가 다를 수 있습니다. - 보드게임 주사위는 **
ROUND(RANDOM() * 6, 0)**입니다. 결과를 예측할 수 없으므로 고정된 출력 대신 사용하라는 의미입니다.
OUTPUT ROUND(RANDOM() * 6, 0)
English
Fill a trace table
- A trace table is a dry run. One row is one pass of the loop. You write the variables after that pass.
Totalstarts at 0. AfterI = 1it is 1. AfterI = 2it is 3. AfterI = 3it is 6.
| I | Total |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
한국어
추적 표(trace table) 채우기
- 추적 표는 수동 실행(dry run)입니다. 한 행은 루프의 한 번 반복(integration)입니다. 변수는 해당 반복 후의 값을 기록하십시오.
- **
Total**는 0으로 시작합니다.I = 1후에는 1,I = 2후에는 3,I = 3후에는 6이 됩니다.
| I | 총계(Total) |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
Explore · 탐색하기
One row per pass · 한 번의 반복마다 한 줄씩
A trace table records each variable after that pass of the loop. Here Total is the running sum of I. · 추적 표는 루프의 각 반복 후 모든 변수를 기록합니다. 여기에서 Total은 I의 누적 합계입니다.
DECLARE I, Total : INTEGER
Total ← 0
FOR I ← 1 TO 3
Total ← Total + I
OUTPUT I, " ", Total
NEXT I
English
Watch out
- Round a half only when you have checked the digit. The tasks here are not on a halfway value.
RANDOM()is notRAND.RANDbelongs to the 9618 guide, not to this syllabus.
한국어
주의사항
- 반올림할 때는 오직 반절(halfway)일 때만 확인해야 합니다. 여기의 작업들은 반절 값이 아닙니다.
- **
RANDOM()**는 **RAND**이 아닙니다. **RAND**은 이 교재 과정이 아닌 9618 가이드에 속합니다.
English
Common mistakes
ROUNDtakes the value first and the number of places second.- In a trace, record the values after the line has run, not the values you hope the next line will produce.
한국어
흔한 실수
- **
ROUND**는 먼저 값을,次に 자릿수(number of places)를 취합니다. - 추적에서는 기대되는 다음 줄의 결과가 아니라, 해당 줄이 실행된 후의 실제 값을 기록하십시오.
English
Now you try
- The first task is
ROUND. The second prints a trace, one row per line. - Press Check answer to test it.
한국어
이제 직접 해보기
- 첫 번째 작업은 **
ROUND**입니다. 두 번째 작업은 추적을 출력하며, 한 줄에 한 행씩 나타냅니다. - 답안 확인을 눌러 테스트해 보십시오.
Output ROUND(3.14159, 2) and ROUND(9.6, 0), each on its own line. · ROUND(3.14159, 2)과 ROUND(9.6, 0)을 각각 별도의 줄에 출력하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
Start Total at 0. For I from 1 to 3, add I to Total and output I, a space, and Total on that line. The three lines are the trace. · Total를 0로 시작합니다. I가 1부터 3까지일 때, I을 Total에 더하고 해당 줄에 I, 공백, 그리고 Total을 출력합니다. 이 세 줄이 바로 추적표입니다.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.