Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How to input a number? Not a=int(input('A=')). It is like int c=(a*a+b*b) in c++. I want this in phyton 3

0 votes
asked Mar 25, 2021 by AzECeFeR (200 points)

2 Answers

–1 vote
answered Mar 25, 2021 by KKN (1,110 points)
edited Mar 26, 2021 by KKN

I will attempt to answer your question, although next time, please be more clear; at least show us your existing code.

#Assuming b = 2
b=2
#Error Handling
try:
    #Gets user input, explicitly converts to int
    a = int(input("A="))

    #Whatever math formula THAT is :P
    c = a*a+b*a

except ValueError:
    print("ValueError: Input must be integer, not string.")
else:
    #Prints c if nothing goes wrong
    print(c)

Hopefully that answered your question

~ KK

commented Mar 26, 2021 by KKN (1,110 points)
Why the dislike? Is something wrong with my code?
commented Mar 26, 2021 by KKN (1,110 points)
ahhhh, I just noticed
0 votes
answered Mar 27, 2021 by Divyansh Jain (140 points)
a=int(input("Enter A:"))
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...