AritmatikaDemo.py

Berikut hasil perhitungan sederhana dengan python.
Yang mana soal saya ambil dari buku JENI.

#!/usr/bin/env python3
#Created by: Ronald Stevens
#Filename: ArtimatikaDemo.py


#Variabel yang akan di itung
i = 37
j = 42
x = 27.475
y = 7.22
<!--more-->
print("Berikut ini adalah output program,")

print("Variable values..")
print("i = ",i)
print("j = ",j)
print("x = ",x)
print("y = ",y)

#Penjumlahan
print("Adding...")
print("i + j = ",i+j)
print("x + y = ",x+y)

#Pengurangan
print("Subtracting...")
print("i - j = ",i-j)
print("x - y = ",x-y)

#Perkalian
print("Multiplying...")
print("i * j = ",i*j)
print("x * y = ",x*y)

#Pembagian
print("Dividing...")
print("i / j = ",i/j)
print("x / y = ",x/y)

#Sisa hasil bagi
print("Computing the remainder...")
print("1 % j = ",i%j)
print("x % y = ",x%y)

#Mencampur tipe variabel
print("Mixing types...")
print("j + y = ",j+y)
print("i * x = ",i*x)
Both comments and trackbacks are currently closed.
%d blogger menyukai ini: