Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

Pozivanje iz funkcije

Pozivanje iz funkcije 26.08.2007. u 14:16 · pre 234 meseca #1

import math
a=input(int)
b=input(int)
c=input(int)


def jed():
b*b-4*a*c
if b*b-4*a*c<0:
math.sqrt(math.sqrt((b*b-4*a*c)*(b*b-4*a*c)))*(-1)
return math.sqrt(math.sqrt((b*b-4*a*c)*(b*b-4*a*c)))*(-1)
else:
math.sqrt(b*b-4*a*c)
return math.sqrt(b*b-4*a*c)



jed()
if b*b-4*a*c<0:
print math.sqrt(math.sqrt((b*b-4*a*c)*(b*b-4*a*c)))*(-1)
else:
print math.sqrt(b*b-4*a*c)



ovo je kod koji racuna vrijednost determinante kod kvadratne jednadzbe.
kako zamijeniti "b*b-4*a*c" sa varijablom d?
umjesto math.sqrt(math.sqrt((b*b-4*a*c)*(b*b-4*a*c)))*(-1) i math.sqrt(b*b-4*a*c) da vrati za svaki dio jednu varijablu?
Re: Pozivanje iz funkcije 26.08.2007. u 15:00 · pre 234 meseca #2
stavis samo d= b*b-4*a*c
Potpis
The earth teaches us more about ourselves than all the books. Because it resists us. Man discovers himself when he measures himself against the obstacle.
Re: Pozivanje iz funkcije 26.08.2007. u 15:49 · pre 234 meseca #3
javi gresku?
jel treba varijablu d incijalizirati?
a umjesto kobasica da stavim varijablu?
kad stavim neku varijablu, javi gresku.
Re: Pozivanje iz funkcije 26.08.2007. u 16:10 · pre 234 meseca #4
Ne stavljas odmah direktno, vec u funkciji jed()
Potpis
The earth teaches us more about ourselves than all the books. Because it resists us. Man discovers himself when he measures himself against the obstacle.
Re: Pozivanje iz funkcije 27.08.2007. u 00:26 · pre 234 meseca #6
prost primer:
Code:


import math
a = input('Unesi broj: ')
b = input('Unesi 2 broj: ')

def pitagorina_teorema():
    d = a**2+b**2
    return math.sqrt(d)

print pitagorina_teorema()
Potpis
The earth teaches us more about ourselves than all the books. Because it resists us. Man discovers himself when he measures himself against the obstacle.
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme