︠f0e86a33-4dc2-4743-9061-e7cc8150884ai︠ %html
# The pound sign--also known as "crunch", "hash", "number sign", or "octothorpe"--denotes a comment
Look at the following code. It assigns values to a and b and then their sum to c.
Note that when you press the Enter key in Sage Notebook the expression is not evaluated. Either click "evaluate" or press Shift-Enter. Do so now.
︡c22bc1da-7511-4f1e-a1c2-06d86ae42a78︡{"html": "# The pound sign--also known as \"crunch\", \"hash\", \"number sign\", or \"octothorpe\"--denotes a comment
Look at the following code. It assigns values to a and b and then their sum to c.
Note that when you press the Enter key in Sage Notebook the expression is not evaluated. Either click \"evaluate\" or press Shift-Enter. Do so now.
"}︡ ︠daecf605-9cdd-42db-911d-aa13c7d3059b︠ a=3 b=2 c=a+b ︡87201c76-c5c2-4744-853f-a863e555a6e5︡︡ ︠3b85a4cf-d31e-4c1b-a4fb-7e31890b9ac1i︠ %htmlNote that assignments are evaluated but not displayed. To display a previously defined variable, type its name on a line by itself or in a different input cell.
︡d3680de8-6e47-47d3-a9c8-ed955a6c98df︡{"html": "Note that assignments are evaluated but not displayed. To display a previously defined variable, type its name on a line by itself or in a different input cell.
"}︡ ︠11360130-b1e9-414e-9a3f-c8f48efa1566︠ c ︡5bf2ef6d-46ee-4bf9-9c26-474c147ce8f2︡{"stdout": "5"}︡ ︠0926b819-129b-4830-a045-5948f1d73beai︠ %htmlLike Python, changing the value of a will not change the value of c.
︡71c53f2e-9080-4824-8896-fdba75d19dc7︡{"html": "Like Python, changing the value of a will not change the value of c.
"}︡ ︠b9c549d2-76de-4282-9b84-6f47a8cc7466︠ a=7 c ︡a87d2349-cc8b-49ee-a1a4-1225e2244c1b︡{"stdout": "5"}︡ ︠40dfb7c0-865f-4bb5-bf15-cc000e79e6a1i︠ %htmlComparison to Python
1. The exponent operater. Evaluate the following cell in both Sage and Python modes. When executed in Python, 4^2=6. Python inherited the designation of '^' as the bitwise XOR operator from C/C++. For an explanation of bitwise XOR, see: http://irc.essex.ac.uk/www.iota-six.co.uk/c/e4_bitwise_operators_and_or_xor.asp
︡75728a99-e49c-4a3c-80fe-9ea29437ede8︡{"html": "Comparison to Python
\n1. The exponent operater. Evaluate the following cell in both Sage and Python modes. When executed in Python, 4^2=6. Python inherited the designation of '^' as the bitwise XOR operator from C/C++. For an explanation of bitwise XOR, see: http://irc.essex.ac.uk/www.iota-six.co.uk/c/e4_bitwise_operators_and_or_xor.asp
"}︡ ︠179d920a-0e61-4ca7-b148-31cebec090b8︠ d=3**2 print 'd = ',d e=4^2 print 'e = ',e ︡53722a27-ee66-4ffc-ae61-b0d0b8b09e54︡{"stdout": "d = 9\ne = 6"}︡ ︠2235502a-2f69-4105-bfc6-4ac315c27cddi︠ %html2. Division with '/'. Evaluate the following cell in sage and Python
︡99afef38-0ed4-4e10-a66c-474b021e9c5a︡{"html": "2. Division with '/'. Evaluate the following cell in sage and Python
"}︡ ︠eae0bfc7-a374-46ff-8ebe-1090c6cbeeee︠ d=10/5 print 'd = ',d e=2/3 print 'e = ',e ︡4b3fd0b7-014a-4bb3-acd4-83b798798f1b︡{"stdout": "d = 2\ne = 0"}︡