0
Python variable
Input A=int(input ("enter the Ist number")) B=int(input ("enter the IInd number")) C=A+B Print (C) Output Error. Why And some code running and getting output but I didn't run in output like Input name= input("enter your name") print = ("hi "+ name) Output Enter your name But I didn't type in output only see Why I don't understand what is problem
3 Answers
+ 5
Python is case sensitive. So A, B and a, b are treated as four different variables. You should match the variable names' cases when interacting with them. Additionally, You need to use print, not Print, as it is case sensitive. Correct code:
A=int(input("enter the Ist number"))
B=int(input("enter the IInd number"))
C=A+B
print(C)
I'd also suggest you to use lower case for variable names, not that it is always required but it is recommended by the naming convention.
EDIT FOR THE NEW CODE: there is no = needed for print, you did not use it in the first code and you don't use it in this either. When you run the code, you should get a popup asking for input. Type a name. there and click submit, the output should be "hi name" where name is the input you gave.
+ 5
You only need to give input. When you run the code you get output.
As suggested above, try using lower case in your variable. That is a better practice to avoid minor errors
The error you getting is for your print() statement. There is no = needed for printing name.
All you do is:
name = input ()
print('hi' + name)
• input() by default takes strings like name, day, and more
• int(input ()) prints integers/numbers
I hope this will help you.
0
VIP ROHAN , in your codes, I noticed the following mistakes:-
Code 1. Python is case-sensitive. And the correct function is print() #all lowercase.
So, writing Print(*argument*) results in a NameError.
Instead, use: print(*argument*).
Code 2: Using print = () will make the computer think that 'print' is the name of a variable because you have assigned a string value to it by using the '=' symbol (= is an assignment operator).
So now, print is no longer a function, it has become a string and as a result the computer is not able to show any output (other than the input prompt).
Instead, use: print('hi '+name)
#print('hi',name) also works because comma (,) adds a space automatically.
Note- even if you type print(print) in the next line hoping to get the desired output, it is not going to work. This will result in a TypeError.
Hope this helps.