Skip to content

Commit c65cc9f

Browse files
authored
Merge pull request #117 from danx3300607/main
250441100014_Wildan_Firdaus_Modul5_KakSalman
2 parents 231add9 + 3d1d029 commit c65cc9f

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

modul-5/Soal-No1.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def factorial(n):
2+
if n == 0 or n == 1:
3+
return 1
4+
else:
5+
return n * factorial(n - 1)
6+
7+
n = int(input("Masukkan bilangan bulat non-negatif: "))
8+
9+
if n < 0:
10+
print("Faktorial tidak dapat dihitung untuk bilangan negatif.")
11+
else:
12+
print("Faktorial dari", n, "adalah:", factorial(n))
13+
14+
15+
16+
17+
18+

modul-5/Soal-No2.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def cek_anagram(kata1, kata2):
2+
kata1 = kata1.lower()
3+
kata2 = kata2.lower()
4+
return sorted(kata1) == sorted(kata2)
5+
6+
kata1 = input("Masukkan kata pertama: ")
7+
kata2 = input("Masukkan kata kedua: ")
8+
9+
if cek_anagram(kata1, kata2):
10+
print("Kedua kata tersebut adalah anagram!")
11+
else:
12+
print("Kedua kata tersebut bukan anagram.")

modul-5/Soal-No3.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def hitung_gaji(nama, jabatan, gaji_pokok):
2+
if jabatan == "manager":
3+
tunjangan = gaji_pokok * 0.10
4+
elif jabatan == "staff":
5+
tunjangan = gaji_pokok * 0.05
6+
else:
7+
tunjangan = 0
8+
9+
gaji_kotor = gaji_pokok + tunjangan
10+
pajak = 0.05 * gaji_kotor
11+
gaji_bersih = gaji_kotor - pajak
12+
13+
print("=== Rincian Gaji Karyawan ===")
14+
print("Nama Karyawan :", nama)
15+
print("Jabatan :", jabatan)
16+
print("Gaji Pokok : Rp", gaji_pokok)
17+
print("Tunjangan : Rp", tunjangan)
18+
print("Gaji Kotor : Rp", gaji_kotor)
19+
print("Pajak (5%) : Rp", pajak)
20+
print("=" * 50)
21+
print("Gaji Bersih : Rp", gaji_bersih)
22+
23+
nama = input("Masukkan nama karyawan: ")
24+
jabatan = input("Masukkan jabatan (manager/staff): ")
25+
gaji_pokok = int(input("Masukkan gaji pokok: "))
26+
27+
hitung_gaji(nama, jabatan, gaji_pokok)

0 commit comments

Comments
 (0)