Hi Everyone
I'm taking a basic coding class, and while I like it so far, my teacher doesn't really have a knack for teaching, so I'm finding it very difficult to understand. We're translating mathematical expressions into Python and I'm only on #2 and struggling. Lol.
I'm a little embarrassed to show what I've tempted, but whatever.
So this is the expression: n(n-1)/2
And here is the terrible code I attempted:
I'm taking a basic coding class, and while I like it so far, my teacher doesn't really have a knack for teaching, so I'm finding it very difficult to understand. We're translating mathematical expressions into Python and I'm only on #2 and struggling. Lol.
I'm a little embarrassed to show what I've tempted, but whatever.
So this is the expression: n(n-1)/2
And here is the terrible code I attempted:
def main(): n=float(input("Enter value for n: ")) ans1=n*(n-1) ans2=ans1/2 print("The answer is:", ans2)And then I get an error when I try to run it. I figure the trouble is the middle part when I try and solve the expression, but Idk how to fix it.