Fakultas Ilmu Komputer UI

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

reupload

parent dc7864d5
import urllib.request
page = urllib.request.urlopen("https://skycruiser8.github.io/PF1Demo/")
datas = page.read().decode("utf8")
datas = datas.split("\n")
index = 0
print(datas)
while index < len(datas)-1:
nama_agen = datas[index]
permintaan_kuota = int(datas[index+1])
if nama_agen[:8] == "Koperasi":
tipe_perusahaan = "koperasi"
kuota_maks = 15000
else:
tipe_perusahaan = "PT."
kuota_maks = 20000
if permintaan_kuota > kuota_maks:
print(nama_agen," melebihi kuota maks", kuota_maks,"tabung")
else:
if permintaan_kuota > 0.75*kuota_maks:
print(nama_agen," adalah agen",tipe_perusahaan," Kelas I")
else:
if permintaan_kuota > 0.5*kuota_maks:
print(nama_agen,"adalah agen",tipe_perusahaan," kelas J")
else:
print(nama_agen,"adalah agen",tipe_perusahaan," kelas K")
index = index+2
import urllib.request
page = urllib.request.urlopen("https://stevensim226.github.io/TP4/jadwal")
text = page.read().decode("utf8")
japi = text.split("<tr>")
lows = text.lower()
japi2 = lows.split("<tr>")
print("Selamat Datang di jadwal-manager!")
print("Silahkan pilih perintah = jadwal, detail, exit")
perintah = " "
while perintah != "exit":
perintah = input("masukkan perintah: ")
if perintah == "jadwal":
for i in japi:
finder = i.find('<td class="mata-kuliah">')
if finder != -1:
a = i.find(">")
b = i.find("</td>")
print(i[a+1:b])
elif perintah == "detail":
matkul = input("mata kuliah apa yang ingin anda lihat detail?: ")
matkul2 = matkul.lower()
for i in japi2:
if matkul2 in i:
p = i.find('<td class="waktu">')
q = i.find('</td>\n <td class="ruangan">')
r = i.find('<td class="ruangan">')
s = i.find('</td>\n </tr>\n')
jam = i[p+18:q]
listjam = jam.split()
listjam = listjam[1:]
startjam, mulaimenit = listjam[0].split(':')
startjam = int(startjam)
mulaimenit = int(mulaimenit)
endjam, akhirmenit = listjam[2].split(':')
endjam = int(endjam)
akhirmenit = int(akhirmenit)
print("nama mata kuliah: {}".format(matkul.title()))
print("diadakan pada setiap: {}".format(jam))
print("diadakan di ruangan: {}".format(i[q+38:s]))
print("berlangsung selama: {} jam {} menit".format(endjam-startjam, akhirmenit-mulaimenit))
else:
print("perintah tidak ditemukan, pastikan input anda benar!")
print("terimakasih sudah menggunakan jadwal manager!")
\ No newline at end of file
import urllib.request
page = urllib.request.urlopen("https://stevensim226.github.io/TP4/statistics")
text = page.read().decode("utf8")
first_li_pos = 0
first_li_close_pos = 0
kucing = 0
kuliah = 0
mahasiswa = 0
kantin = 0
kos = 0
tugas = 0
tidakDitemukan = 0
hastag_tidakDitemukan = ""
while text.find("<li>",first_li_pos+1) and text.find("</li>",first_li_close_pos+1) != -1:
open_li = text.find("<li>",first_li_pos+1)
close_li = text.find("</li",first_li_close_pos+1)
found = False
if "kucing" in text[open_li+4:close_li].lower():
kucing += 1
found = True
elif "kuliah" in text[open_li+4:close_li].lower():
kuliah += 1
found = True
elif "mahasiswa" in text[open_li+4:close_li].lower():
mahasiswa += 1
found = True
elif "kantin" in text[open_li+4:close_li].lower():
kantin += 1
found = True
elif "kos" in text[open_li+4:close_li].lower():
kos += 1
found = True
elif "tugas" in text[open_li+4:close_li].lower():
tugas += 1
found = True
elif not found:
tidakDitemukan += 1
hastag_tidakDitemukan += text[open_li+4:close_li] + " "
first_li_pos = open_li
first_li_close_pos = close_li
print("terdapat {} post untuk hashtag kucing".format(kucing))
print("terdapat {} post untuk hashtag kuliah".format(kuliah))
print("terdapat {} post untuk hashtag mahasiswa".format(mahasiswa))
print("terdapat {} post untuk hashtag kantin".format(kantin))
print("terdapat {} post untuk hashtag kos".format(kos))
print("terdapat {} post untuk hashtag tugas".format(tugas))
print("terdapat {} post untuk dengan hashtag tidak terklasifikasi".format(tidakDitemukan))
print("dengan hashtag: {}".format(hastag_tidakDitemukan))
import urllib.request
import urllib.parse
page = urllib.request.urlopen("https://ceritanyatuwiter.herokuapp.com/1906399915")
text = page.read().decode("utf8")
print(text)
disalurkan = 1
#stok_sekarang =
#laporkan_stok =
stok = ambil_info_stok()
def laporkan_stok:
param = urllib.parse.urlencode({"pesan":"Stok Terkini: stok_sekarang"})
resp = urllib.request.urlopen("https://ceritanyatuwiter.herokuapp.com/1906399915/lapor",param.encode())
def ambil_info_stok:
while stok >0 and disalurkan > 0:
disalurkan = input("masukkan jumlah tabung yang disalurkan: ")
if disalurkan > 0:
if disalurkan > stok:
print("stok tidak cukup")
else:
print("penyaluran jumlah disalurkan tabung berhasil. sekarang tersisa stok - disalurkan")
laporkan_stok(stok - disalurkan)
stok = ambil_info_stok()
\ No newline at end of file
import urllib.request
page = urllib.request.urlopen("https://pudyprima.github.io/prices.html")
text = page.read().decode("utf8")
print(text)
cek_teks = ">$"
i = 0
Found = False
while i < len(text) -1 and not Found:
if text[i:i+2] == cek_teks:
Found = True
i += 1
if Found == True:
print(text[i:i+5])
else:
print("tidak ada")
kalimat = input("tulis sebuah kalimat: ")
counter = 0
for i in kalimat:
counter += 1
print("ada",counter)
\ No newline at end of file
nama = input("tuliskan sebuah nama: ")
spasi = nama.replace(" ","")
counter = 0
for i in spasi:
counter += 1
print("ada",counter,"tanpa spasi")
\ No newline at end of file
nama1 = input("masukkan nama 1: ")
nama2 = input("masukkan nama 2: ")
if nama2 in nama1:
print("ada","'",nama2,"' di '",nama1,"'")
else:
print("tidak ada","'",nama2,"' di '",nama1,"'")
\ No newline at end of file
import urllib.request
page = urllib.request.urlopen("https://skycruiser8.github.io/PF1Demo/")
text = page.read().decode("utf8")
google = input("cari kata didalam website tersebut: ")
if google in text:
print("ada kata","'",google,"'","pada alamat https://skycruiser8.github.io/PF1Demo/")
else:
print("tidak ada kata '",google,"' dalam kalimat https://skycruiser8.github.io/PF1Demo/ ")
\ 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