You are viewing a single comment's thread. Return to all comments →
my first expected value a+b comes up as 325, why?
a = int(raw_input(3))
b = int(raw_input(2))
Your Output (stdout)
I experienced the same output. So I decided to see what it thought 'a' was:
So, why does the first iteration of 'a' believe it is 323?
Ok, I figured it out. When you try to use static values it results in the 325 1 6. Example of static values 3 & 2:
a=int(raw_input(3)) b=int(raw_input(2)) etc...
When I remove the static values then the process works:
a=int(raw_input()) b=int(raw_input()) etc...
I assume the input values (3, 2) are provided as part of the test case when executed.
what do you mean by remove static values, Im having the same issue
Its not because of static values .Its because the Python work on REPL i.e,
R - Read
E - Execute
P - Print
L - Loop
So here when a = raw_input(3) is given it Reads the command, Execute it i.e takes a as input 3, Prints it i.e why it prints 3 and then 2 for b = raw_input(2) and then Loop back again i.e it waits to read next instruction.
Hence your output is like
moreover Python considers your inputs as strings and they're concatenated when you don't convert them explicitly. That's why you get such errors.
you don't have to provide the values while declaring the variable. It will be provided by the program during compile time.
So the code would be:
i guess it is because of raw_input() which cconsiders the console input as string and your program is doing string concatenation.
The argument inside raw_input("argument") will print the argument on the console.