Input & Output in Python

Hello

Hi, This time i want to share How to create Input and Output using the Python language, immediately wrote i love the examples of input and output with ease so that you can learn it.

Creating Student Input Output

nama_mhs = str(input("Masukan Nama Anda = "))
nim_mhs = str(input("Masukan NIM Anda = "))
kelas_mhs = str(input("Masukan Kelas Anda = "))
umur = str(input("Masukan Umur Anda = "))
 
print("")
print("")
tampilInfoMhs = "Detail dari Informasi Anda..\n\nNama Anda Adalah : "+nama_mhs+"\nNim Anda Adalah : "+nim_mhs+"\nAnda berada dikelas : "+kelas_mhs+"\nBerumur : "+umur
print(tampilInfoMhs)
print("Nama Anda adalah {} dengan nim {} bernama {} dan berumur {}".format(nama_mhs, nim_mhs, kelas_mhs, umur))

Explanation on program example above:

Make An Input and output, you just need to type in the editor or IDLE python Pycharm you.

VARIABEL --> nama_mhs, nim_mhs, kelas_mhs & umur
INPUT STRING (BUKAN NUMERIK) --> str(input("Masukan Nama Anda = ")) ATAU input("Masukan Nama Anda = ")
OUTPUT --> print();
UNTUK MEMBUAT SPACE BARU --> \n
UNTUK MENGABUNGKAN --> + (misal +variabel+)

Makes Numbers Input 3 integers

bil1 = int(input("Masukan Bilangan ke-1 = "))
bil2 = int(input("Masukan Bilangan ke-2 = "))
bil3 = int(input("Masukan Bilangan ke-3 = "))
 
print("")
jumlah = bil1**+(bil2/bil3)-bil3
print("Hasilnya adalah = ", jumlah)

Explanation on program example above:

Make An Input and output, you just need to type in the editor or IDLE python Pycharm you.

VARIABEL --> bil1, bil2, bil3
INPUT NUMERIK (Bukan Kalimat) --> int(input("Masukan Bilangan ke-3 = "))
OUTPUT --> print("")
OPERATOR --> * (Perkalian), + (Pertambahan), / (Pembagian), - (Pengurangan)

Creating Time Program and Seconds

v = float(input("Masukan Kecepatan = "))
s = int(input("Masukan Jarak yang Ditempuh = "))
 
t = v/s
print("")
print("Hasilnya adalah = ", t)

Explanation on program example above:

Make An Input and output, you just need to type in the editor or IDLE python Pycharm you.

Here there are two examples of input that is input numbers numeric and real number, actually the same, equally number numeric only the difference if dibilangan ril (Float) using a comma, if you use a number coma in Numerical it is not very effective and make the program compile much memory as possible the program could be an error.

VARIABEL --> v,s
INPUT NUMERIK --> int(input("Masukan Jarak yang Ditempuh = "))
INPUT BILANGAN RIL --> float(input("Masukan Kecepatan = "))
OPEARTOR --> / (Pembagian)
OUTPUT --> print("Hasilnya adalah = ", t)

Calculation Bus and Student

kapasitas = 25
jumlah_siswa = int(input("Jumlah Siswa = "))
bus = jumlah_siswa//kapasitas
sisa = jumlah_siswa%kapasitas
print("Bus yang akan digunakan = ", bus)
print("Sisa Siswanya adalah = ", sisa)

Explanation on program example above:

Make An Input and output, you just need to type in the editor or IDLE python Pycharm you.

VARIABEL --> kapasitas, jumlah_siswa, bus, sisa
INPUT NUMERIK --> int(input("Jumlah Siswa = "))
PERHITUNGAN --> jumlah_siswa//kapasitas , jumlah_siswa%kapasitas
OPERATOR --> & (Sisa Bagi), // (Hasil Bagi)
OUTPUT --> print("Sisa Siswanya adalah = ", sisa)

Age Difference Program

nama_1 = str(input("Nama 1 = "))
umur_1 = int(input("Umur 1 = "))
nama_2 = str(input("Nama 2 = "))
umur_2 = int(input("Umur 2 = "))
selisih = abs(umur_1-umur_2)
print("Selisih umur",nama_1,"dan",nama_2,"adalah",selisih,"tahun")

Explanation on program example above:

Make An Input and output, you just need to type in the editor or IDLE python Pycharm you.

VARIABEL --> nama_1, umur_1, selisih
INPUT KALIMAT --> str(input("Nama 1 = "))
INPUT BILANGAN --> int(input("Umur 1 = "))
PERHITUNGAN --> abs(umur_1-umur_2)
OUTPUT --> print("Selisih umur",nama_1,"dan",nama_2,"adalah",selisih,"tahun")

Output word of Variable

a = "ponco"
b = "kun"
c = "'hinata say'"
print(a,b,c)

Explanation on program example above:

Make An Input and output, you just need to type in the editor or IDLE python Pycharm you.

VARIABEL --> a,b,c
OUTPUT --> print(a,b,c)

Source Code?

You guys please check on this site:

– https://github.com/poncoe/python_basic/tree/master/bab1_input_output
– https://github.com/poncoe/python_basic

Post Author: Study