From 2d14d4fecfa6283342eb8d05e8d6fca193e37405 Mon Sep 17 00:00:00 2001 From: iqbalfau Date: Tue, 21 Mar 2017 20:47:33 +0700 Subject: [PATCH 1/4] Update answer1.py --- DataLatihan/answer1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/DataLatihan/answer1.py b/DataLatihan/answer1.py index a489c87..3e9f573 100644 --- a/DataLatihan/answer1.py +++ b/DataLatihan/answer1.py @@ -7,3 +7,21 @@ def readData(data1): for line in data : x = line.split() return x + +x = readData(data1) +txt = [] +for i in x: + if (i == 'I' ): + txt.append('*') + elif (i == 'and'): + txt.append('***') + elif (i == 'The'): + txt.append('***') + elif (i == 'you'): + txt.append('***') + else : + txt.append(i) + +txt = ' '.join(txt) + +print(txt) From 8131304805602861c945e5d4bf8a65f8fc7e4c83 Mon Sep 17 00:00:00 2001 From: iqbalfau Date: Tue, 21 Mar 2017 20:48:19 +0700 Subject: [PATCH 2/4] Update answer2.py --- DataLatihan/answer2.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/DataLatihan/answer2.py b/DataLatihan/answer2.py index 5d28fd2..da70b38 100644 --- a/DataLatihan/answer2.py +++ b/DataLatihan/answer2.py @@ -2,8 +2,27 @@ data2 = "Data2.txt" def readData(data1): - x = [] - with open(data1) as data : - for line in data : - x = line.split() -return x + x = [] + with open(data1) as data : + for line in data : + x = line.split() + return x + +a = readData(data1) +b = readData(data2) +c = [] +for i in a : + + count = 0 + for x in b: + if (i == x): + count += 1 + for y in c: + if (y == i): + count=0 + if (count!=0): + c.append(i) + +c = ' '.join(c) + +print(c) From 7e312e3ce2580ef49ea62efe4c3a674fad87eb1e Mon Sep 17 00:00:00 2001 From: Iqbal Fauzi Date: Tue, 28 Mar 2017 16:04:00 +0700 Subject: [PATCH 3/4] Create Answer --- DataTugas/Answer | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 DataTugas/Answer diff --git a/DataTugas/Answer b/DataTugas/Answer new file mode 100644 index 0000000..47b9745 --- /dev/null +++ b/DataTugas/Answer @@ -0,0 +1,41 @@ +data1 = "DataSet.txt" + +def readData(data1): + x = [] + with open(data1) as data : + for line in data : + x = line.split() + return x +data = readData(data1) + +hasil = [] +hasil2 = [] +angka = [] +titik = False +for i in data: + x = i + + if x.isdigit(): + angka.append(x) + hasil.append('w') + else: + if titik == True : + y = x[0].upper() + x[1:] + titik = False + hasil.append(y) + else: + hasil.append(x) + if x.endswith('.'): + titik = True +angka.reverse() +y=0 +for i in hasil : + if i == 'w': + hasil2.append(angka[y]) + y+=1 + else : + hasil2.append(i) + +hasil2 = ' '.join(hasil2) + +print(hasil2) From eba377c8d49a0ba49d5590a5ba02eae0bd8cbdce Mon Sep 17 00:00:00 2001 From: Iqbal Fauzi Date: Tue, 28 Mar 2017 16:04:43 +0700 Subject: [PATCH 4/4] Rename Answer to Answer.py --- DataTugas/{Answer => Answer.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename DataTugas/{Answer => Answer.py} (100%) diff --git a/DataTugas/Answer b/DataTugas/Answer.py similarity index 100% rename from DataTugas/Answer rename to DataTugas/Answer.py