Fakultas Ilmu Komputer UI

Commit 0caf9463 authored by Ahmad Dzikrul Fikri's avatar Ahmad Dzikrul Fikri
Browse files

Tugas Pemrograman 7 - Tahap 2 - 1806196806

parent 09d3e4fd
def ambil_data(angka_minimal):
try:
data = open('input_order1.txt')
data_input = []
data_baru= open('TP7_output1_1806196806.txt','w')
for jumlah in data:
data_input.append(jumlah)
data_input.sort(reverse=True)
for line in range(len(data_input)):
if int(data_input[line]) >= angka_minimal:
data_baru.write(data_input[line])
data_baru.close()
data.close()
except:
print("None")
try:
minimal = int(input("masukkan angka minimal :"))
except:
print("input harus berupa angka tanpa alfabet")
ambil_data(minimal)
\ No newline at end of file
def urut_data(angka_minimal):
try:
data = open('input_order2.txt')
data_akhir =''
data_order = []
data_input =[]
for line in data:
nama, jumlah = line.split()
data_input.append(nama+' '+jumlah)
data_order.append(jumlah)
data_order.sort(reverse=True)
data.close()
if data_order[0] == data_order[-1]:
for index in range(len(data_input)):
data_akhir += data_input[index] +'\n'
else:
for i in range(len(data_order)):
if data_order[i] != data_order[i-1]:
for index in range(len(data_input)):
if data_input[index].find(data_order[i]) != -1 :
data_akhir += data_input[index] + '\n'
data_baru= open('TP7_output2_1806196806.txt','w')
awal = 0
akhir = 0
for line in range(minimal):
akhir = data_akhir.find('\n', awal)
data_baru.write(data_akhir[awal:akhir]+'\n')
awal = akhir + 1
data_baru.close()
except:
print("None")
uji_eror = True
while uji_eror == True:
try :
minimal = int(input("masukkan jumlah data dengan order tertinggi yang ingin anda lihat :"))
uji_eror = False
except :
print("input harus berupa angka tanpa alfabet")
urut_data(minimal)
\ No newline at end of file
500
499
499
498
497
497
496
495
494
492
489
487
485
485
481
480
478
478
477
477
477
476
476
474
468
466
463
463
457
456
455
453
453
451
450
446
445
443
442
437
437
436
433
433
432
432
428
428
428
426
422
419
418
415
412
410
410
406
405
404
404
401
400
EIFLA 500
NAWE 499
LEAH 499
ELLIOT 498
EVA 497
Markdown is supported
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