Python Forum
In need help to put this code in order
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In need help to put this code in order
#3
(Apr-10-2019, 06:37 AM)j.crater Wrote: Hello, for starters
def Gos_Erlang(A,C):
This function does not return any value, which is ok, but the problem would be line #17 - gos d (which by the way is not allowed variable name due to whitespace).
And function def (gos, C): needs a name.

I am having issues with the last define function, its telling me that the return is undefined

import math

def fact(n):
    ans = 1
    for i in range(2 , n + 1):
        ans*=i
    return ans
    
def Gos_erlang(A0,n):
    numera = math.pow(A0 , n) / fact(n)
    denomi = 0
    for k in range(0, n+1):
        denomi += math.pow( A0 , k ) / fact(k)
    Gos = numera / denomi
    return Gos
Gos = float(input('Enter Gos : '))
n = int(input('Enter n : '))

def E_erlang(Gos, A0):
    a=0
    b=n
    c=0
    while abs(a-b)>0.000001:
        c=(a+b)/2
        Gos_c=Gos_erlang(c,n)
        if Gos_c<Gos:
            a=c
        else:
            b=c
    return Gos_c
print('Capacity :', c)
Reply


Messages In This Thread
RE: In need help to put this code in order - by lekuru01 - Apr-10-2019, 05:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help!! Order form and receipt code beginner1996 2 3,417 Mar-07-2019, 03:22 PM
Last Post: beginner1996
  Write a code to output in alphabetical order AbdelaliPython 1 4,748 Jan-19-2018, 09:03 PM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020