Variables Practice

What will be printed to the screen after running each of these snippets of code? Talk to a partner and write down your answers. Then, see if you were right by writing the examples in a file named variables_practice.py and running the file from the command line.

What is the outcome of running the code below?

a = 25
b = 36
print a * b

What is the outcome of running the code below?

dog = "Ralph"
cat = "Whiskers"

print dog + cat

What is the outcome of running the code below?

band = "The Beatles"

print "My favorite band is " + band

Write the code to find the difference between the product and sum of three numbers

  1. Set x equal to 34679
  2. Set y equal to 566
  3. Set zequal to 47
  4. Output the product of x,y, and z
  5. Assign the product to a variable
  6. Output the sum of x,y, and z
  7. Assign the sum to a variable
  8. Output the difference between the product and the sum