Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Can I ask a python question?

Can I ask a question about python that will be answered? Real python questions, not coco. Else, could you recommend another coding site that I can ask a python question on?

2 Likes

Yes, I think I could answer some questions, I do do actual Python. :snake:
:lion: :lion: :lion:

def um(a):
    count=0
    w=input("If you're done, type (\'d\'). What are your numbers? (One at a time, please) : ")
    while True:
        if w==1:
            break
        else:
            h.append(w)
    for i in h:
        count+=i
    return count

def product():
    h=[]
    while True:
        w=input("If you're done, type (\"d\"). What are your numbers? (One at a time, please) : ")
        if w=="d":
            break
        h.append(w)
        
    count=1
    for i in h:
        count=count*i
    return count

def quotient():
    a=input("Divisor: ")
    b=input("Dividend: ")
    h=input("With remainder (r), or not (n)?: ")
    h=h.lower()
    if h=='r':
        x=int(a/b)
        y=a%b
        c=f"The number is {x}, and the remainder is {y}!"
        return c
    elif h=="n":
        s=a/b
        return s

def difference():
    a=input("Minuend: ")
    b=input("Subtrahend: ")
    c=a-b
    return c

def exponent():
    a=input("What number?: ")
    b=input("What exponent?: ")
    c=a**b
    return c

def calculator():
    '''
    Literally a calculator
    '''
    while True:
        w=input("Multiplication (m), Division (d), Subtraction (s), or Addition (a), Exponent (e), or Put away your calculator (p)?: ")
        w=w.lower()
        if w=="p":
            break
        if w== "e":
            exponent()
        if w=="s":
            print(difference())
        if w=="d": #division
            return print(quotient())
        if w=="a": #addition
            return print(um())
        if w=="m": #multiplication
            return print(product())
        print("Cha-Chok.")



calculator()

I’m trying to make a calculator (for fun) and It doesn’t work.

Checked only the Multiplication:

def product():
    # code
        h.append(w) # error:  make all computed string values numbers
        h.append(float(w))

and the product will work. The other functions also have similar errors. Checked the code in http://pythontutor.com / The input screen is bottom left /
I support the idea to have two new sections: JavaScript/CoffeScript/ Help and Python Help where to post similar questions.
At this site you can also get live help.

3 Likes

THANK YOU SO MUCH!! :rice_ball::rice_ball::rice_ball::rice_ball::rice_ball::rice_ball::rice_ball::rice_ball::rice_ball::grinning::grinning::grinning::grinning::grinning::grinning::grinning:

Hello, I am posting this here and on reddit, I need help with this code:

def rps():
    a=str(input("What is your name?: "))
    b=str(input("And your name?"))
    c=str(input(f"{a}, do you want to choose rock(r), paper(p), or scissors(s)?: "))
    e="NO CHEATING! \n"
    print(e*100)
    d=str(input(f"{b}, do you want to choose rock(r), paper(p), or scissors(s)?: "))
    if a=="r"or a=="p"or a=="s" and b=="r"or b=="p"or b=="s":
        if a==b:
            print("It's a tie!")
        elif a=="r":
            if b=="p":
                print(f"{b} wins!")
            elif b=="s":
                print(f"{a} wins!")
        elif a=="p":
            if b=="r":
                print(f"{a} wins!")
            elif b=="s":
                print(f"{b} wins!")
        elif a=="s":
            if b=="p":
                print(f"{a} wins!")
            elif b=="r":
                print(f"{b} wins!")
        g=str(input("Play again? Yes(y) or no(n)?: ")
        if g=="y":#error
            rps()#error
        elif g=="n":
            print("Ok then. Bye!" )
        else:
            print("I'm assuming that's a no. Bye!")
rps()

help!

I changed some name variables and corrected the if statement:

def rps():
    aGamer=str(input("What is your name?: "))
    bGamer=str(input("And your name?"))
    aGamerChoice=str(input(f"{aGamer}, do you want to choose rock(r), paper(p), or scissors(s)?: "))
    e="NO CHEATING! \n"
    print(e*100)
    bGamerChoice=str(input(f"{bGamer}, do you want to choose rock(r), paper(p), or scissors(s)?: "))
    if (aGamerChoice=="r"or aGamerChoice=="p"or aGamerChoice=="s") and (bGamerChoice=="r"or bGamerChoice=="p"or bGamerChoice=="s"):
        if aGamerChoice==bGamerChoice:
            print("It's a tie!")
# so on ...

rps()

Use meaningful names. You can continue alone and ask later if difficulties…

I figured out that I hadn’t put a parentheses on the end of a line. Oh, computers. Thanks for helping me, though.