← Academy curriculum

Variables, units and algorithms

විචල්‍ය, ඒකක සහ ඇල්ගොරිතම

Programming fundamentals · Self-study · Virtual first

AI-generated illustrative engineering concept; not an actual Zenvayra facility
AI-generated illustrative concept; use verified diagrams for connections.

Understand the conceptසංකල්පය තේරුම් ගන්න

An algorithm is an ordered method for solving a problem. A variable stores a value, and a type constrains its representation. Use meaningful names and include units in names or comments. Separate input, processing and output.

ඇල්ගොරිතමයක් යනු ගැටලුවක් විසඳන පිළිවෙළකි. විචල්‍යයක අගයක් ගබඩා වේ. දත්ත වර්ගය එම අගය නිරූපණය කරන ආකාරය තීරණය කරයි. ආදානය, සැකසීම හා ප්‍රතිදානය වෙන් කරන්න.

Worked exampleවිසඳූ උදාහරණය

distanceCm = 18; thresholdCm = 20; stop = distanceCm < thresholdCm; produces true.

distanceCm = 18 සහ thresholdCm = 20 නම් stop = distanceCm < thresholdCm හි අගය true වේ.

Practice independentlyස්වාධීනව පුහුණු වන්න

Write pseudocode to read a temperature, compare with 30 °C, and output an alert. Test 29, 30 and 31; choose and document the exact boundary.

උෂ්ණත්වය කියවා 30 °C සමඟ සසඳා අනතුරු ඇඟවීමක් ලබා දෙන ව්‍යාජ කේතයක් ලියන්න. 29, 30 සහ 31 පරීක්ෂා කරන්න.

Virtual lab / අතථ්‍ය පරීක්ෂණාගාරය ↗
Compare your reasoning (model answer)ඔබේ හේතු සමඟ සසඳන්න (උදාහරණ පිළිතුර)

One possible rule: alert = temperatureC >= 30. Outputs at 29, 30, 31: false, true, true. A different boundary is acceptable if documented.

උදාහරණ නියමය: alert = temperatureC >= 30. 29, 30, 31 සඳහා false, true, true.

Knowledge checkදැනුම පරීක්ෂාව

Why include units in a variable name?විචල්‍යයක නමට ඒකකය එක් කරන්නේ ඇයි?

Choose an answer first.