Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions DataLatihan/answer1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
29 changes: 24 additions & 5 deletions DataLatihan/answer2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
41 changes: 41 additions & 0 deletions DataTugas/Answer.py
Original file line number Diff line number Diff line change
@@ -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)