Difference between revisions of "Tugas 1"

From ccitonlinewiki
Jump to: navigation, search
(Created page with " def soal(x): pembilang = x**2-1 penyebut = x -1 try: hasil = pembilang/penyebut except ZeroDivisionError: hasil = float('inf') return hasil limx = 1 limb = limx + 0...")
 
Line 1: Line 1:
 +
<nowiki>def soal(x):
 +
pembilang = x**2-1
 +
penyebut = x -1
 +
try:
 +
hasil = pembilang/penyebut
 +
except ZeroDivisionError:
 +
hasil = float('inf')
 +
return hasil
  
 +
limx = 1
 +
limb = limx + 0.5
 +
limp = 0.05
 +
limx1 = limx - limp
 +
hasilnya = 0
 +
while limx < limb+ 0.5:
 +
#print(limx1)
 +
limx1 =limx1 + 0.01
 +
print(soal(limx1))
 +
limx = limx + 0.1
 +
if soal(limx1) != float('inf'):
 +
#print(soal(limx1))
 +
hasilnya = hasilnya + soal(limx1)
 +
 +
 +
print("hasil limitnya = ")
 +
print(hasilnya/9)
 +
</nowiki>
 
def soal(x):
 
def soal(x):
 
pembilang = x**2-1
 
pembilang = x**2-1

Revision as of 11:58, 9 September 2019

def soal(x): pembilang = x**2-1 penyebut = x -1 try: hasil = pembilang/penyebut except ZeroDivisionError: hasil = float('inf') return hasil limx = 1 limb = limx + 0.5 limp = 0.05 limx1 = limx - limp hasilnya = 0 while limx < limb+ 0.5: #print(limx1) limx1 =limx1 + 0.01 print(soal(limx1)) limx = limx + 0.1 if soal(limx1) != float('inf'): #print(soal(limx1)) hasilnya = hasilnya + soal(limx1) print("hasil limitnya = ") print(hasilnya/9) def soal(x): pembilang = x**2-1 penyebut = x -1 try: hasil = pembilang/penyebut except ZeroDivisionError: hasil = float('inf') return hasil

limx = 1 limb = limx + 0.5 limp = 0.05 limx1 = limx - limp hasilnya = 0 while limx < limb+ 0.5: #print(limx1) limx1 =limx1 + 0.01 print(soal(limx1)) limx = limx + 0.1 if soal(limx1) != float('inf'): #print(soal(limx1)) hasilnya = hasilnya + soal(limx1)


print("hasil limitnya = ") print(hasilnya/9)