Created
March 24, 2020 14:29
-
-
Save hndr91/38395f1da15f7be0d40403a18c3bb93f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [ | |
["John", "Tidak", "Tidak"], | |
["Swiper", "Ya", "Ya"], | |
["Boot", "Tidak", "Tidak"], | |
["Roger", "Ya", "Tidak"], | |
["Dora", "Tidak", "Tidak"], | |
["Diego", "Tidak", "Tidak"] | |
] | |
# Pro tips | |
# cek baris 2d list -> len(data) | |
# cek kolom 2d list -> len(data[0]) | |
def cetakData(data, suspect): | |
''' | |
Params : | |
-------- | |
data : 2d list | |
list of potential suspects. List column format nama, bertemu, gejala | |
suspect : str | |
suspect's name | |
''' | |
pdp = 0 | |
odp = 0 | |
print("Tracing interaksi dengan {} COVID-19\n".format(suspect)) | |
print("=======================================\n") | |
print("Nama\t\tBertemu\tGejala\tStatus") | |
print("---------------------------------------\n") | |
for i in range(len(data)): | |
# Cek ODP | |
if data[i][1] == "Ya" and data[i][2] == "Tidak": | |
odp = odp + 1 | |
print("{}\t\t{}\t{}\tODP".format(data[i][0],data[i][1],data[i][2])) | |
# Cek PDP | |
elif data[i][1] == "Ya" and data[i][2] == "Ya": | |
pdp = pdp + 1 | |
print("{}\t\t{}\t{}\tPDP".format(data[i][0],data[i][1],data[i][2])) | |
else: | |
print("{}\t\t{}\t{}\t -".format(data[i][0],data[i][1],data[i][2])) | |
print("---------------------------------------\n") | |
print("Jumlah PDP = {}\n".format(pdp)) | |
print("Jumlah ODP = {}\n".format(odp)) | |
if __name__ == "__main__": | |
suspect = "Mr. X" | |
cetakData(data, suspect) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment