Fakultas Ilmu Komputer UI

Commit 17105877 authored by Ruly Achmad Gemilang Gultom's avatar Ruly Achmad Gemilang Gultom
Browse files

Tugas pemograman ekstra no 1 dan 2 - 1906399915

parent aac9f511
......@@ -2,51 +2,25 @@ try:
a = int(input("masukkan bilangan pertama: "))
b = int(input("masukkan bilangan kedua: "))
c = int(input("masukkan bilangan ketiga: "))
lis = [a,b,c]
lis.sort()
print(lis)
d = a**2
e = b**2
f = c**2
g = (d+e)**0.5
h = (d+f)**0.5
i = (d+g)**0.5
j = (e+f)**0.5
k = (e+g)**0.5
l = (f+g)**0.5
a1 = (d-e)**0.5
a2 = (d-f)**0.5
a3 = (d-g)**0.5
a4 = (e-f)**0.5
a5 = (e-g)**0.5
a6 = (f-g)**0.5
#samasisi
if a == b == c:
print("segitiga sama sisi")
#samakaki
elif a == b or a == c or b == c:
print("segitiga samakaki")
#Siku-siku
elif g == a or g == b or g == c or a1 == a or a1 == b or a1 == c:
print("segitiga siku2")
elif h == a or h == b or h == c or a2 == a or a2 == b or a2 == c:
print("segitiga siku2")
elif i == a or i == b or i == c or a3 == a or a3 == b or a3 == c:
print("segitiga siku2")
elif j == a or j == b or j == c or a4 == a or a4 == b or a4 == c:
print("segitiga siku2")
elif k == a or k == b or k == c or a5 == a or a5 == b or a5 == c:
print("segitiga siku2")
elif l == a or l == b or l == c or a6 == a or a6 == b or a6 == c:
print("segitiga siku2")
#bukan segitiga
elif lis[0] + lis[1] <= lis[2]:
print("bukan segitiga")
if a > 0 and b > 0 and c > 0:
lis = [a,b,c]
lis.sort()
print(lis)
#samasisi
if a == b == c:
print("segitiga sama sisi")
#bukan segitiga
elif lis[0] + lis[1] <= lis[2]:
print("bukan segitiga")
#samakaki
elif a == b or a == c or b == c:
print("segitiga samakaki")
#Siku-siku
elif lis[2]**2 == lis[0]**2 + lis[1]**2:
print("segitiga siku2")
else:
print("segitiga sembarang")
else:
print("segitiga sembarang")
print("Input bukan bilangan bulat positif")
except ValueError:
print("input bukan angka")
\ No newline at end of file
......@@ -6,37 +6,44 @@ def get_data(datas):
text = data.read().decode("utf8")
return text
except urllib.error.HTTPError:
print("Link Tidak Ditemukan!")
return None
datas1 = "https://pudyprima.github.io/covid19-jakarta"
datas1 = "https://pudyprima.github.io/covid19-jakart"
#memanggil fungsi get_data()
print(get_data("https://pudyprima.github.io/covid19-indonesia"))
print(get_data("https://pudyprima.github.io/covid19-jakarta"))
def get_data_per_wilayah(wilayah):
awal = get_data(datas1).lower()
awal = get_data(datas1)
if awal == None:
return None
awal = awal.lower()
wilayah = wilayah.lower()
ai = awal.find("<td>"+ str(wilayah) +"</td>")
print("ai =",ai)
if ai != -1:
lu = awal.find("<td>",ai+3)
le = awal[lu+4:lu+7]
la = awal.find("</td>",lu+3)
le = awal[lu+4:la]
return le
else:
f = "kota tidak Ditemukan!"
return f
return None
#memanggil fungsi get_data_per_wilayah
print(get_data_per_wilayah("Jakarta Barat"))
def get_data_jakarta():
p = int(get_data_per_wilayah("Jakarta Barat"))
q = int(get_data_per_wilayah("Jakarta Timur"))
r = int(get_data_per_wilayah("Jakarta Pusat"))
s = int(get_data_per_wilayah("Jakarta Selatan"))
t = int(get_data_per_wilayah("Jakarta Utara"))
tambah = p+q+r+s+t
return tambah
try:
p = int(get_data_per_wilayah("Jakarta Barat"))
q = int(get_data_per_wilayah("Jakarta Timur"))
r = int(get_data_per_wilayah("Jakarta Pusat"))
s = int(get_data_per_wilayah("Jakarta Selatan"))
t = int(get_data_per_wilayah("Jakarta Utara"))
tambah = p+q+r+s+t
return tambah
except:
return None
#memanggil fungsi get_data_jakarta
print(get_data_jakarta())
......@@ -44,16 +51,14 @@ print(get_data_jakarta())
def get_total_kasus_by_keyword(keyword):
try:
global datas1
datas1 = "https://pudyprima.github.io/covid19-indonesia"
keyword = keyword.lower()
datak = str(get_data(datas1))
datakk = datak.lower()
counter = datakk.count(keyword)
return counter
except TypeError or AttributeError:
nono = "Bukan jenis Keyword! silahkan input kembali"
return nono
except:
return "Bukan jenis Keyword! silahkan input kembali"
#memanggil fungsi get_total_kasus_by_keyword
print(get_total_kasus_by_keyword("jawa tengah"))
\ No newline at end of file
print(get_total_kasus_by_keyword("22"))
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment