Sequence, input & output · Urutan, input & output
A program runs in order
- A program is a list of steps.
- Python runs them from top to bottom, one at a time.
- This order is called sequence — the first idea in the syllabus.
Program berjalan berurutan
- Program adalah daftar langkah-langkah.
- Python menjalankannya dari atas ke bawah, satu per satu.
- Urutan ini disebut sekuens — ide pertama dalam silabus.
print("Wake up")
print("Brush teeth")
print("Go to school")
OUTPUT becomes print()
- In the exam, OUTPUT shows something on the screen.
- In Python, that is
print(). - The text inside the quotes is printed, then a new line starts.
OUTPUT menjadi print()
- Dalam ujian, OUTPUT menampilkan sesuatu di layar.
- Di Python, itu adalah
print(). - Teks di dalam tanda kutip dicetak, lalu baris baru dimulai.
print("Hello, world!")
print("IGCSE Computer Science")
INPUT becomes input()
- In the exam, INPUT reads what the user types.
- In Python, that is
input(). - It always gives back a string (text), even if the user types digits.
INPUT menjadi input()
- Dalam ujian, INPUT membaca apa yang diketik pengguna.
- Di Python, itu adalah
input(). - Selalu mengembalikan string (teks), bahkan jika pengguna mengetik angka.
name = input()
print("Hello, " + name)
Turn input into a number
input()gives text, so"5"is not the number 5.- Wrap it with
int()to get a whole number. - Now you can do maths with it.
Ubah input menjadi angka
input()memberikan teks, jadi"5"bukan angka 5.- Bungkus dengan
int()untuk mendapatkan bilangan bulat. - Sekarang Anda bisa melakukan matematika dengannya.
age = int(input())
print(age + 1)
In the exam: pseudocode
- The same idea in Cambridge pseudocode uses
INPUTandOUTPUT.
Dalam ujian: pseudocode
- Ide yang sama dalam pseudocode Cambridge menggunakan
INPUTdanOUTPUT.
OUTPUT "What is your name?"
INPUT Name
OUTPUT "Hello, ", Name
Common mistakes
- Statements run from top to bottom, in the order you write them.
input()gives back text (a string); useint(...)when you need a number.
Kesalahan umum
- Pernyataan dijalankan dari atas ke bawah, sesuai urutan penulisan Anda.
input()mengembalikan teks (string); gunakanint(...)ketika Anda membutuhkan angka.
Now you try
- Use
print()to show output. - Use
input()to read a line — leave the brackets empty here. - Press Check answer to test your code.
Sekarang Anda coba
- Gunakan
print()untuk menampilkan output. - Gunakan
input()untuk membaca baris — biarkan kurung kosong di sini. - Tekan Periksa jawaban untuk menguji kode Anda.
Input → process → output · Input → proses → output
Most programs follow one shape: get input, do something, show output. · Sebagian besar program mengikuti satu bentuk: dapatkan input, lakukan sesuatu, tampilkan output.
Print these three lines, in order: Ready, then Set, then Go — one per line. · Cetak tiga baris ini, berurutan: Ready, lalu Set, lalu Go — satu per baris.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Read a name with input(), then print Hello, then the name then !. For the input Sam, the output should be Hello, Sam!. · Baca nama dengan input(), lalu cetak Hello, kemudian nama lalu !. Untuk input Sam, output seharusnya Hello, Sam!.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Read a whole number with input(), convert it with int(...), then print it doubled (times 2). For input 6, the output should be 12. · Baca satu nombor bulat dengan input(), tukar ia dengan int(...), kemudian cetak ia berlipat dua (daripada 2). Untuk input 6, output sepatutnya ialah 12.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.