• simple math program

    From Darkman Almighty@1337:3/129 to All on Fri Feb 12 18:42:27 2021
    Ok, I'm trying to write a math program for fun... asks what operation you wanna






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































    run.. and then how many numbers. I got it to work for adding.. but subtracting






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































    no so much. Heres what I have for that

    def minus():
    num =input ("How many numbers you want to subtract? ")
    num = int(num)
    result = []
    for i in range(num):
    number=int(input(f'Please enter the (i+1) value :'))
    result.append(int((number)))
    def sub(number):
    total=0
    for i in number:
    total - = i
    return total
    print ("your total is:, (sub(result)))

    I ran this and it seems to add the numbers as a negative interger. Thoughts?

    Darkman Almighty

    --- Mystic BBS v1.12 A47 2021/01/26 (Raspberry Pi/32)
    * Origin: 2o fOr beeRS bbs>>>20ForBeers.com:1337 (1337:3/129)
  • From dbasher@1337:3/106 to Darkman Almighty on Sat Feb 13 07:31:41 2021
    I ran this and it seems to add the numbers as a negative interger. Thoughts?

    def sub(number):
    total=0
    for i in number:
    total - = i
    return total

    total -= i is the same as total = total - i

    You start off by setting total to 0, and hence get negative integers since
    you start subtracting from 0.

    dbasher

    --- Mystic BBS v1.12 A45 2020/02/18 (Linux/64)
    * Origin: The Bottomless Abyss BBS * bbs.bottomlessabyss.net (1337:3/106)
  • From Darkman Almighty@1337:1/101 to dbasher on Wed Feb 17 02:30:40 2021
    On 13 Feb 2021, dbasher said the following...

    I ran this and it seems to add the numbers as a negative interger. Thoughts?

    def sub(number):
    total=0
    for i in number:
    total - = i
    return total

    total -= i is the same as total = total - i

    You start off by setting total to 0, and hence get negative integers sinceyou start subtracting from 0.

    dbasher

    ok ok, this makes some sense... now the question is should I even have a line setting the total. I'll try and play around with this a bit.. but at least I have a direction. Thanks!

    --- Mystic BBS v1.12 A47 2020/12/04 (Linux/64)
    * Origin: thE qUAntUm wOrmhOlE, rAmsgAtE, uK. bbs.erb.pw (1337:1/101)
  • From dbasher@1337:3/106 to Darkman Almighty on Wed Feb 17 11:07:13 2021
    ok ok, this makes some sense... now the question is should I even have a line setting the total. I'll try and play around with this a bit.. but
    at least I have a direction. Thanks!

    You should probably initialize the total with the first number in the list instead of 0.

    dbasher

    --- Mystic BBS v1.12 A45 2020/02/18 (Linux/64)
    * Origin: The Bottomless Abyss BBS * bbs.bottomlessabyss.net (1337:3/106)