String handling · التعامل مع النصوص
LENGTH counts characters
LENGTH(s)gives how many characters are in a string.
LENGTH يحسب عدد الأحرف
LENGTH(s)يعطي عدد الأحرف الموجودة في السلسلة النصية.
OUTPUT LENGTH("hello") // → 5
UCASE and LCASE change case
UCASE(s)makes a string all CAPITALS.LCASE(s)makes it all lower case.
UCASE و LCASE يغيران حالة الأحرف
UCASE(s)يجعل السلسلة النصية كلها بأحرف كبيرة.LCASE(s)يجعلها كلها بأحرف صغيرة.
OUTPUT UCASE("abc") // → ABC
OUTPUT LCASE("HeLLo") // → hello
SUBSTRING takes part of a string
SUBSTRING(s, start, length)copies part of a string.- The first character is position 1 (not 0).
SUBSTRING يستخرج جزءاً من السلسلة النصية
SUBSTRING(s, start, length)ينسخ جزءاً من السلسلة النصية.- الحرف الأول هو الموضع 1 (وليس 0).
OUTPUT SUBSTRING("Computer", 1, 4) // → Comp
Printing several values
OUTPUTtakes several values separated by commas and prints them one after another.- The 0478 pseudocode has no "join" operator — a comma is how you put values side by side.
طباعة عدة قيم
OUTPUTيقبل عدة قيم مفصولة بـ فواصل وطباعتها واحداً تلو الآخر.- الكود الوهمي 0478 لا يحتوي على عامل "join" — الفاصلة هي الطريقة لوضع القيم جنباً إلى جنب.
DECLARE Lives : INTEGER
Lives ← 3
OUTPUT "Cam", "bridge" // → Cambridge
OUTPUT "You have ", Lives, " lives left"
Common mistakes
- Learn the exam's function names:
LENGTH,SUBSTRING,UCASE,LCASE. - String positions in pseudocode often start at
1, not0.
أخطاء شائعة
- احفظ أسماء الدوال في الامتحان:
LENGTH،SUBSTRING،UCASE،LCASE. - مواقع السلاسل النصية في الكود الوهمي تبدأ غالباً من
1، وليس0.
Now you try
- Use the string functions above.
- Press Check answer to test it.
الآن جرب بنفسك
- استخدم دوال السلاسل النصية المذكورة أعلاه.
- اضغط على تحقق من الإجابة لاختبارها.
Read a word, then output how many characters it has with LENGTH. For input hello, output 5. · اقرأ كلمة، ثم أخرج عدد أحرفها باستخدام LENGTH. بالنسبة للإدخال hello، أخرج 5.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
Read a word and output it in CAPITALS with UCASE. For input cat, output CAT. · اقرأ كلمة وأخرجها بأحرف كبيرة باستخدام UCASE. بالنسبة للإدخال cat، أخرج CAT.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
Read a word and output its first 3 letters with SUBSTRING (start at 1, length 3). For input Computer, output Com. · اقرأ كلمة وأخرج أول 3 أحرف منها باستخدام SUBSTRING (ابدأ من 1، الطول 3). بالنسبة للإدخال Computer، أخرج Com.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.