<jupyter_start><jupyter_text>Mengingat NumPy<jupyter_code>import numpy as np
np_tinggi = np.array([1.73, 1.68, 1.71, 1.89, 1.79])
np_berat = np.array([65.4, 59.2, 63.6, 88.4, 68.7])
bmi = np_berat / np_tinggi ** 2

bmi
bmi > 23
bmi[bmi > 23]<jupyter_output><empty_output><jupyter_text>Komparasi Numerik<jupyter_code>2 < 3
2 == 3
2 <= 3
3 <= 3
x = 2
y = 3
x < y<jupyter_output><empty_output><jupyter_text>Komparasi yang lain<jupyter_code>'dian' < 'diantemi'
3 < 'dian'
3 < 4.1
bmi
bmi > 23
# < 
# <= 
# > 
# >= 
# == 
# !=<jupyter_output><empty_output><jupyter_text>Boolean Operator<jupyter_code># and, or, not
True and True
False and True
True and False
False and False
x = 12
x > 5 and x < 15
True or True
False or True
True or False
False or False
y = 5
y < 7 or y > 13
not True
not False<jupyter_output><empty_output><jupyter_text>Kembali ke NumPy<jupyter_code>bmi
bmi > 21
bmi < 22
bmi > 21 and bmi <22
 np.logical_and(bmi > 21, bmi < 22) #np.logical_and np.logical_or np.logical_or
bmi[np.logical_and(bmi > 21, bmi < 22)]<jupyter_output><empty_output><jupyter_text>if, elif, else (conditional statement)<jupyter_code>z = 4
if z % 2 == 0 :
    print("z adalah genap")
z = 4
if z % 2 == 0:
    print("Mengecek " + str(z))
    print("z adalah genap")
z = 5 # TIDAK TEREKSEKUSI KARENA FALSE
if z % 2 == 0:
    print("Mengecek " + str(z))
    print("z adalah genap")
z = 5
if z % 2 == 0 :
    print("z adalah genap")
else :
    print("z adalah ganjil")
z = 3
if z % 2 == 0:
    print("z habis dibagi 2")
elif z % 3 == 0:
    print("z habis dibagi 3")
else :
    print("z tidak habis dibagi 2 maupun 3")
z = 6
if z % 2 == 0:
    print("z habis dibagi 2")
elif z % 3 == 0:
    print("z habis dibagi 3")
else :
    print("z tidak habis dibagi 2 maupun 3")<jupyter_output>z habis dibagi 2<jupyter_text>Filtering pandas<jupyter_code>import pandas as pd
df = pd.read_csv('negara.csv', index_col=0)
df<jupyter_output><empty_output><jupyter_text>- Tujuan: Mencari Negara dengan dengan luas diatas 8 juta km^2<jupyter_code>df['area'] #  alternatif df.loc[:,"area"] atau df.iloc[:,2]
df['area'] > 8
cek_gedene = df['area'] > 8
df[cek_gedene]<jupyter_output><empty_output><jupyter_text>Menggunakan Boolean Operator<jupyter_code>import numpy as np
np.logical_and(df["area"] > 8, df["area"] < 10)
df[np.logical_and(df["area"] > 8, df["area"] < 10)]<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup