1. Labتاقیگە

Loop trace tableخشتەی بەدواداچوونی خول

A shows what happens inside a : one row for every step, one column for every . Step through the same program in , or , like in an , guess each new value before the computer shows it and collect stars.

پیشان دەدات لە ناو چی ڕوودەدات: بۆ هەر هەنگاوێک و بۆ هەر . هەنگاو بە هەنگاو بە ناو هەمان بڕۆ بە ، یان ، وەک لە ، پێش ئەوەی نیشانت بدات هەر نوێ پێشبینی بکە و ئەستێرە کۆ بکەرەوە.

Programبەرنامە
CêIT IDE

    OUTPUT

     

    What a trace table isخشتەی بەدواداچوون چییە

    Definitionپێناسە

    A table you fill in by hand to follow a program or an step by step: one column for each and for the , one row for each step. It shows exactly where a happens.

    خشتەیەکە بە دەست پڕی دەکەیتەوە بۆ ئەوەی هەنگاو بە هەنگاو بەدوای یان بچیت: ستوونێک بۆ هەر و بۆ ، هەروەها ڕیزێک بۆ هەر هەنگاوێک. بە وردی پیشان دەدات لە کوێدا ڕوو دەدات.

    1. Make one column for every , plus columns for the line number and the .

      بۆ هەر دروست بکە، لەگەڵ ژمارەی دێڕ و .

    2. Run the code in your head, one line at a time, from the top.

      کۆدەکە لە مێشکی خۆتدا جێبەجێ بکە، هەر جارە دێڕێک، لە سەرەوە.

    3. Every time a value changes, write a new row with the new value. Never rub out old rows: they show the history.

      هەر جارێک دەگۆڕێت، نوێ بە نرخە نوێیەکە بنووسە. مەسڕەوە: مێژووەکە پیشان دەدەن.

    4. At a loop line, write whether the loop runs again (and the new value of its ).

      لە دێڕی ، بنووسە کە ئایا دووپاتە دەخولێتەوە یان نا (لەگەڵ نرخی نوێی ).

    5. Compare your table with what the prints. If they differ, you have found the .

      خشتەکەت لەگەڵ ئەوەی چاپی دەکات بەراورد بکە. ئەگەر جیاواز بوون، دۆزیوەتەوە.

    The first program, tracedیەکەم بەرنامە، بەدواداچوونی بۆ کراوە

    PythonPythonPYTHON
    total = 0
    for i in range(1, 6):
        total = total + i
    print(total)
    Java (inside main)Java (لە ناو main)JAVA
    int total = 0;
    for (int i = 1; i <= 5; i++) {
        total = total + i;
    }
    System.out.println(total);
    PHPPHPPHP
    <?php
    $total = 0;
    for ($i = 1; $i <= 5; $i++) {
        $total = $total + $i;
    }
    echo $total;

    The Python trace is below. In Java and PHP the loop line appears more often: the i <= 5 is checked before every round and i++ runs after it, so at the end i is 6.

    خشتەی Python لە خوارەوەیە. لە Java و PHPـدا دێڕی زیاتر دەردەکەوێت: i <= 5 پێش هەموو خولێک دەپشکنرێت و i++ دوای ئەو جێبەجێ دەبێت، بۆیە لە کۆتاییدا i دەبێتە 6.

    LineدێڕitotalOutput
    10
    21
    31
    22
    33
    23
    36
    24
    310
    25
    315
    415

    Appearanceڕووکار

    Modeدۆخ
    Styleشێواز
    Coloursڕەنگەکان

    Saved on this device only.تەنیا لەسەر ئەم ئامێرە پاشەکەوت دەکرێت.