This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dapatkan nilai tinggi badan. | |
tinggi_badan = int(input('Tinggi badan: ')) | |
# Dapatkan nilai umur. | |
umur = int(input('Umur: ')) | |
# Cek. | |
if tinggi_badan >= 140 and umur >= 15: | |
print('Selamat menikmati wahana roller coaster!') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dapatkan jenis kelamin. | |
jenis_kelamin = input('Jenis kelamin (L/P): ') | |
# Dapatkan umur. | |
umur = input('Umur: ') | |
# Cek. | |
if umur < 10 or jenis_kelamin == 'P': | |
print('Anda bisa naik') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inisialisasi scanner. | |
Scanner scanner = new Scanner(System.in); | |
// Baca nilai. | |
int nilai = scanner.nextInt(); | |
// Cek nilai. | |
if(nilai >= 90) { | |
System.out.println("A"); | |
} else if(nilai >= 80) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Baca nilai. | |
nilai = int(input('Nilai: ')) | |
# Cek. | |
if nilai >= 90: | |
print("A") | |
else if nilai >= 80: | |
print("B") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inisialisasi scanner. | |
Scanner scanner = new Scanner(System.in); | |
// Baca jenis kelamin. | |
char jenisKelamin = scanner.next().charAt(0); | |
// Baca umur. | |
int umur = scanner.nextInt(); | |
// Cek. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (inisialisasi; kondisi; increment/decrement) { | |
Blok loop; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for indeks in range(batas_atas): | |
Blok loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < 10; i++) { | |
System.out.println("Hello world!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello world! | |
Hello world! | |
Hello world! | |
Hello world! | |
Hello world! | |
Hello world! | |
Hello world! | |
Hello world! | |
Hello world! | |
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i > 10; i++) { | |
// Blok ini tidak akan pernah dieksekusi. | |
System.out.println("Hello world!"); | |
} | |
System.out.println("Keluar dari loop"); |