The Python shell always returns the last evaluated value. When a is 5, it evaluates to 5, so you see it. When you call print , print prints the value (without the quotes) and returns nothing, so after print nothing happens. Thus, evaluating b leads to 'some test' , and printing it simply leads to some text .
source share