Do Now
Type in the following code into a file and save:
a = input("What is your name? ")
# a = "cats and dogs"
# meow
print("Hello there, " + a)
- Read through the code and write down what you expect the printed results to be?
- Run the code and write down the actual printed result?
- Briefly describe what the
#
does? - Briefly describe what
input
does?
Snap to Python
Convert the following to Python code:
Swapping
Copy the following code into your editor.
a = "this sentence should go second"
b = "this sentence should go first."
c = a
a = b
# your code starts here
# your code ends here
print(a)
print(b)
Run the program. What is the output?
Write code to swap the values of variables a
and b
.