Skip to content

Commit 231add9

Browse files
authored
Merge pull request #118 from ilhamrasyid0987-source/main
250441100010_ILhamRasyid_modul1-5_KakSalman
2 parents 185547a + 674ad29 commit 231add9

File tree

15 files changed

+420
-0
lines changed

15 files changed

+420
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
buku = 5000
2+
pensil = 4500
3+
pajak = 10 #persen
4+
5+
membeli3_buku = buku * 3
6+
membeli2_pensil = pensil * 2
7+
8+
total_belanja = membeli3_buku + membeli2_pensil
9+
pajak_belanjaan = total_belanja // pajak
10+
11+
print("total harga memebeli 3 buku : ", membeli3_buku, "rupiah")
12+
print("total harga membeli 2 pensil : ", membeli2_pensil, "rupiah")
13+
print("pajak yang di dapat oleh halim : ", pajak_belanjaan)
14+
total = (membeli3_buku + membeli2_pensil + pajak_belanjaan)
15+
16+
print("jadi total semua harga buku dan pensil halim setelah mendapatkan pajak : ", total)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# menghitung volume dan luas sebuah balok
2+
# panjang = 10cm
3+
# lebar = 6cm
4+
# tinggi = 4cm
5+
6+
panjang = int(input("panjang balok : "))
7+
lebar = int(input("lebar balok : "))
8+
tinggi = int(input("tinggi balok : "))
9+
10+
volume_balok = panjang * lebar * tinggi
11+
luas_balok = 2 * (panjang * lebar) + (panjang * tinggi) + (lebar * tinggi)
12+
13+
print("jadi volume dari balok tersebut adalah = ", volume_balok, "cm^2")
14+
print("jadi luas dari balok tersebut adalah = ", luas_balok, "cm^2")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ada bola dalam sebuah kotak dan bermacam macam warnanya
2+
#warna dan jumlah bola yang diketahui yaitu: bola merah = 8, bola biru = 6,
3+
#dan bola warna acak = 3
4+
5+
import math #python tidak bisa mengetahui apa itu math, factorial atau math, comb
6+
#jadi kita menggunakan def itu sebagai definisi dari combbinasi agar terbaca
7+
8+
def comb(n, r):
9+
return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
10+
11+
#Total bola yang diambil
12+
total_bola = 8 + 6
13+
diambil = 3
14+
15+
kombinasi = comb(total_bola, diambil)
16+
print("jumlah kemungkinan Bola yang terambil :", kombinasi)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0"?>
2+
<flowgorithm fileversion="4.2">
3+
<attributes>
4+
<attribute name="name" value="Soal1Praktikum"/>
5+
<attribute name="authors" value="iamkr"/>
6+
<attribute name="about" value=""/>
7+
<attribute name="saved" value="2025-10-09 09:04:38 PM"/>
8+
<attribute name="created" value="aWFta3I7SzsyMDI1LTEwLTA4OzAxOjMyOjAwIEFNOzE4NjA="/>
9+
<attribute name="edited" value="aWFta3I7SzsyMDI1LTEwLTA5OzA5OjA0OjM4IFBNOzI7MjAwMw=="/>
10+
</attributes>
11+
<function name="Main" type="None" variable="">
12+
<parameters/>
13+
<body>
14+
<declare name="nilai, nk" type="Integer" array="False" size=""/>
15+
<output expression="&quot;Masukkan Nilai&quot;" newline="True"/>
16+
<input variable="nilai"/>
17+
<if expression="nilai &gt;= 100 or nilai &lt;= 0">
18+
<then>
19+
<output expression="&quot;Nilai tidak valid&quot;" newline="True"/>
20+
</then>
21+
<else>
22+
<if expression="nilai&gt;=85">
23+
<then>
24+
<output expression="&quot;Masukkan Nilai kehadiran&quot;" newline="True"/>
25+
<input variable="nk"/>
26+
<output expression="&quot;A&quot;" newline="True"/>
27+
<if expression="nk &gt;=85 and nk &gt;=90">
28+
<then>
29+
<output expression="&quot;Lulus dengan pujian&quot;" newline="True"/>
30+
</then>
31+
<else>
32+
<output expression="&quot;Lulus biasa&quot;" newline="True"/>
33+
</else>
34+
</if>
35+
</then>
36+
<else>
37+
<if expression="nilai&gt;=70 and nilai &lt;84">
38+
<then>
39+
<output expression="&quot;B&quot;" newline="True"/>
40+
</then>
41+
<else>
42+
<if expression="nilai &gt;=60 and nilai &lt;69">
43+
<then>
44+
<output expression="&quot;C&quot;" newline="True"/>
45+
</then>
46+
<else>
47+
<if expression="nilai &gt;=50 and nilai &lt;59">
48+
<then>
49+
<output expression="&quot;D&quot;" newline="True"/>
50+
</then>
51+
<else>
52+
<output expression="&quot;E&quot;" newline="True"/>
53+
</else>
54+
</if>
55+
</else>
56+
</if>
57+
</else>
58+
</if>
59+
</else>
60+
</if>
61+
</else>
62+
</if>
63+
</body>
64+
</function>
65+
</flowgorithm>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
tiket_normal = 50000
2+
3+
usia = int(input("Usia anda sekarang : "))
4+
status = input("Apakah anda pelajar SMA dengan kartu pelajar? (ya/tidak) : ")
5+
nonton_hari = input("Anda nontoh hari apa? : ")
6+
diskon = 0
7+
8+
if usia <12 :
9+
diskon = 50
10+
elif status == "ya":
11+
diskon = 30
12+
elif nonton_hari == "selasa":
13+
diskon = 20
14+
else :
15+
print()
16+
17+
bayar = tiket_normal - (tiket_normal * diskon // 100)
18+
print("uang yang anda bayar : ", bayar)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
jam_parkir = int(input("masukkan lama parkir : "))
2+
vip = input("apakah member vip? (ya/tidak) : ")
3+
4+
if vip == "ya":
5+
biaya = 0
6+
else:
7+
if jam_parkir <= 2:
8+
biaya = 5000
9+
else:
10+
biaya = 5000 + (jam_parkir - 2) * 3000
11+
if biaya > 20000:
12+
biaya = 20000
13+
14+
print("total biaya parkir: Rp", biaya)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
jumlah_baris = int(input("Masukkan jumlah baris lampu: "))
2+
3+
for x in range(1, jumlah_baris + 1):
4+
jumlah_lampu = int(input(f"Masukkan jumlah lampu pada baris ke-{x}: "))
5+
for y in range(1, jumlah_lampu + 1):
6+
if y % 3 == 0:
7+
print(f"Lampu ke-{y} pada baris [{x}] rusak.")
8+
else:
9+
print(f"Lampu ke-{y} pada baris [{x}] menyala.")
10+
if x == jumlah_baris:
11+
print("Periksa sambungan daya utama.")
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
print("Program Hitung Gaji Mingguan")
2+
3+
total_gaji = 0
4+
total_lembur = 0
5+
total_bonus_shift = 0
6+
total_upah_lembur = 0
7+
8+
for hari in range(1, 8):
9+
print(f"\nHari ke-{hari}")
10+
shift_malam = input("Apakah shift malam? (y/n): ")
11+
if shift_malam == "y":
12+
jam_lembur = int(input("Masukkan jam lembur: "))
13+
else:
14+
jam_lembur = 0
15+
16+
gaji_pokok = 100000
17+
bonus_shift = 0
18+
upah_lembur = 0
19+
if jam_lembur == 0:
20+
upah_lembur = 0
21+
elif jam_lembur <= 3:
22+
upah_lembur = jam_lembur * 25000
23+
elif jam_lembur == 4:
24+
upah_lembur = 100000
25+
elif jam_lembur == 5:
26+
upah_lembur = 125000
27+
elif jam_lembur == 6:
28+
upah_lembur = 200000
29+
elif jam_lembur == 7:
30+
upah_lembur = 225000
31+
elif jam_lembur == 8:
32+
upah_lembur = 300000
33+
else:
34+
print("Jam lembur melebihi batas, tidak dihitung.")
35+
upah_lembur = 300000
36+
37+
if shift_malam == "y":
38+
bonus_shift = 50000
39+
40+
total_gaji += gaji_pokok + bonus_shift + upah_lembur
41+
total_lembur += jam_lembur
42+
total_bonus_shift += bonus_shift
43+
total_upah_lembur += upah_lembur
44+
gaji_pokok = gaji_pokok * 7
45+
46+
print("=== Rekap Gaji Mingguan ===")
47+
print("Total jam lembur:", total_lembur, "jam")
48+
print("Total upah lembur: Rp", total_upah_lembur)
49+
print("Total bonus shift malam: Rp", total_bonus_shift)
50+
print("Total gaji pokok: Rp", gaji_pokok)
51+
print("--------------------------------")
52+
print("Total gaji selama seminggu: Rp", total_gaji)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
n = int(input("Masukkan nilai n : "))
2+
3+
for i in range (n , 0 , -1 ) :
4+
for j in range (1 , i + 1):
5+
print(f"{j:>3}", end="")
6+
7+
for k in range((n - i)* 6):
8+
print(" ", end="")
9+
10+
for j in range(i, 0, -1):
11+
print(f"{j:>3}", end="")
12+
13+
print()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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))

0 commit comments

Comments
 (0)