Tampilkan postingan dengan label python programing language. Tampilkan semua postingan
Tampilkan postingan dengan label python programing language. Tampilkan semua postingan

Rabu, 04 Mei 2011

Simple Branching Program for Python

Just sharing the code for all,
You can copy an existing program code below 

print "|#################################################|"
print "|                                                 |"
print "|            PROGRAM GAJI PEGAWAI NEGERI          |"
print "|                                                 |"
print "|#################################################|"
print "|                             created by Luthfirez|"
print "|#################################################|"
print ""

nama  = raw_input ("Nama                : ")
nip   = raw_input ("Nomor Induk Pegawai : ")
gol   = raw_input ("Gol (I/II/II)       : ")
status= raw_input ("Status (K/BK)       : ")
anak  = input     ("Jumlah Anak         : ")

print ""

# Untuk Mendapatkan Gaji Pokok
if   gol == "I":
    gapok = 1000
elif gol == "II":
    gapok = 1500
elif gol == "III":
    gapok = 2000
else :
    print "Maaf Data Tidak Ada"

# Untuk Mendapatkan Tunjangan Suami/Istri
if status == "K":
    tunj = gapok*0.05
elif status == "BK":
    tunj = gapok*0
else :
    print "Massa gak"

# Untuk Mendapatkan Tunjangan Anak
tunjanak = gapok*anak*0.025

# Untuk Mendapatkan Gaji Kotor
gajikotor = gapok+tunj+tunjanak

# Untuk Mendapatkan Pajak
if gol=="I" and status=="K":
    pajak = 0.02*gapok
elif gol=="I" and status=="BK":
    pajak = 0.025*gapok
elif gol=="II" and status=="K":
    pajak = 0.03*gapok
elif gol=="II" and status=="BK":
    pajak = 0.035*gapok
elif gol=="III" and status=="K":
    pajak = 0.04*gapok
elif gol=="III" and status=="BK":
    pajak = 0.045*gapok
else :
    print "Maaf Data Tidak Ada"

print "####################################################"
print "#              Maka Informasi Untuk Anda           #"
print "####################################################"
print ""
print "Nama                                : ",nama
print "NIP                                 : ",nip
print "Golongan                            : ",gol
print "Status                              : ",status
print "Jumlah Anak                         : ",anak
print "Gaji Pokok                          :  Rp.",gapok
print "Tunjangan Suami/Istri               :  Rp.",tunj
print "Tunjangan Anak                      :  Rp.",tunjanak
print "Gaji Kotor                          :  Rp.",gajikotor
print "Pajak                               :  Rp.",pajak
print "Total Gaji Bersih (Gaji Kotor-Pajak):  Rp.",gajikotor-pajak
print ""
print "###################################################"

and the result will be as follows



 

Sample Looping Programs for Python 2

Just sharing the code for all,
You can copy an existing program code below

a = input ("enter the initial number : ")
b = input ("want to repeat how many times? : ")
c = str(a)
t = 10
while 0<=b:
    while a<=b-1:
        print c
        a = a+1
        d = str(a)
        c = c+d
   
    print c[:b]
    b=b-1

and the result will be as follows

Sample Looping Programs for Python 1

Just sharing the code for all,
You can copy an existing program code below

a = raw_input("insert the word: ")
b = input("Want to repeat how many times?")
c = 1
while 1<=b:
    while c<=b-1:
        print a*c
        c=c+1
    print a*b
    b=b-1

and the result will be as follows