0
i dont get the spam and eggs
dont know how it ends up as a number
3 odpowiedzi
+ 1
Are you talking about the last question of the Variable lesson?
What is the output of this code?
>>> spam = 2
>>> eggs = 3
>>> del spam
>>> eggs = 4
>>> spam = 5
>>> print(spam*eggs)
spam and eggs are here names for integer variables, ie they hold a number. Here are an example of variables holding text:
>>> spam = "foo"
>>> eggs = "bar"
>>> print(spam)
foo
>>> print(eggs)
bar
Text is represented by a chain of characters between a pair of quotes or double quotes, and that is called a string.
Another example, with spam and eggs as text and not variable names:
>>> print("spam")
spam
>>> print("eggs")
eggs
0
What is the output of this code?
>>> spam = 2
>>> eggs = 3
>>> del spam
>>> eggs = 4
>>> spam = 5
>>> print(spam*eggs)
ans is 20
0
@Shahin Hossain.....thanks, 20 is the correct answer