14,422,174 members
Rate this:
See more:
```import csv
def fuzzy(pr,ps,pt,hr,hs,ht):
ya = [0,0,0]
tidak = [0,0,0,0,0,0]

if (pr > 0)  and (hr > 0):
tidak[0] = min (pr,hr);
if (ps>0)  and (hr >0):
tidak[1] = min (ps,hr);
if (pt>0)  and (hr >0):
tidak[2] = min (pt,hr);
if (pr>0)  and (hs >0):
ya[0] = min (pr,hs);
if (ps>0)  and (hs >0):
tidak[3] = min (ps,hs);
if (pt>0)  and (hs >0):
tidak[4] = min (pt,hs);
if (pr>0)  and (ht >0):
ya[1] = min (pr,ht);
if (ps>0)  and (ht >0):
ya[2] = min (ps,ht);
if (pt>0)  and (ht >0):
tidak[5] = min (pt,ht);

return max(ya),max(tidak)

def defuzzy(ya,tidak):
return ((ya * 60) + (tidak *35)) / (ya + tidak)

def tes_kmptn(kompetensi):
pr = 0;
ps = 0;
pt = 0;

if (kompetensi >= 1.5):
pt =1 ;
elif (kompetensi > 1) and (kompetensi <1.5):
ps = (1.5 - kompetensi)/(1.5 - 1);
pt = 1 - ps;
elif (kompetensi > 0.5) and (kompetensi < 1):
pr = (1 - kompetensi) / (1 - 0.5);
ps = 1 - pr;
elif (kompetensi <= 0.5):
pr = 1;

return pr, ps, pt

hr = 0;
hs = 0;
ht = 0;

ht = 1;
hs = ( 66 - kepribadian)/(66-44);
ht = 1 - hs;
hs = 1;
hr = 1;
return hr,hs,ht;

with open('book1.csv') as file:
with open('TebakanTugas3.csv', 'w', newline='') as data:
fiedlname =['ID','kompetensi','Hutang']
writer = csv.DictWriter(data,fiedlname)
hR,hS,hT = kompetensi(float(row[1]))
pR, pS, pT = Hutang(float(row[2]))
ya, tidak = fuzzy(pR,pS,pT,hR,hS,hT)
x = defuzzy(ya, tidak)
if(x >=60):
print('No', row[0],' penghasian',row[1],' hutang',row[2],' layak mendapatkan BLT')
writer.writerow({'No':row[0],'kompetensi':row[1],'Hutang':row[2]})```

What I have tried:

```import csv
def fuzzy(pr,ps,pt,hr,hs,ht):
ya = [0,0,0]
tidak = [0,0,0,0,0,0]

if (pr > 0)  and (hr > 0):
tidak[0] = min (pr,hr);
if (ps>0)  and (hr >0):
tidak[1] = min (ps,hr);
if (pt>0)  and (hr >0):
tidak[2] = min (pt,hr);
if (pr>0)  and (hs >0):
ya[0] = min (pr,hs);
if (ps>0)  and (hs >0):
tidak[3] = min (ps,hs);
if (pt>0)  and (hs >0):
tidak[4] = min (pt,hs);
if (pr>0)  and (ht >0):
ya[1] = min (pr,ht);
if (ps>0)  and (ht >0):
ya[2] = min (ps,ht);
if (pt>0)  and (ht >0):
tidak[5] = min (pt,ht);

return max(ya),max(tidak)

def defuzzy(ya,tidak):
return ((ya * 60) + (tidak *35)) / (ya + tidak)

def tes_kmptn(kompetensi):
pr = 0;
ps = 0;
pt = 0;

if (kompetensi >= 1.5):
pt =1 ;
elif (kompetensi > 1) and (kompetensi <1.5):
ps = (1.5 - kompetensi)/(1.5 - 1);
pt = 1 - ps;
elif (kompetensi > 0.5) and (kompetensi < 1):
pr = (1 - kompetensi) / (1 - 0.5);
ps = 1 - pr;
elif (kompetensi <= 0.5):
pr = 1;

return pr, ps, pt

hr = 0;
hs = 0;
ht = 0;

ht = 1;
hs = ( 66 - kepribadian)/(66-44);
ht = 1 - hs;
hs = 1;
hr = 1;
return hr,hs,ht;

with open('book1.csv') as file:
with open('TebakanTugas3.csv', 'w', newline='') as data:
fiedlname =['ID','kompetensi','Hutang']
writer = csv.DictWriter(data,fiedlname)
hR,hS,hT = kompetensi(float(row[1]))
pR, pS, pT = Hutang(float(row[2]))
ya, tidak = fuzzy(pR,pS,pT,hR,hS,hT)
x = defuzzy(ya, tidak)
if(x >=60):
print('No', row[0],' penghasian',row[1],' hutang',row[2],' layak mendapatkan BLT')
writer.writerow({'No':row[0],'kompetensi':row[1],'Hutang':row[2]})```
Posted
Updated 21-Apr-19 23:07pm

Rate this:

## Solution 1

We are not a code conversion service: learn Python, learn C. then you can do it yourself.

Even better, learn C and use the Python code as a "specification" for your C code, as direct translations do not generally produce good code in the target language.
v2
Rate this:

## Solution 2

You need to visit some Learn C tutorial to learn the basic of that language to understand and work with it. The compiler will tell you what it doenst understand.

This way looks a function and the and-operator in C
```int maximum(int a, int b)
{
if( (a > b) && (b < a) )
{
return a;
}
return b;
}```