Running a python program, input, output and variables
First things first, make sure your Python environment is working and that you can write and run a program.
This will bring up the interactive command line interface, where you can type lines of code and Python will immediately interpret them:
Run a print
command, just like in the example above, to print a string that describes the beauty of a cherry blossom under the summer moon. Or, you know, whatever.
Grab your neighbor and do this part together on one computer!
For each of the following lines of code, agree (out loud!) about what you think will happen. Then run it and see what Python does. If it's not what you expected, discuss why. Don't skip predicting the output!
Make a list together (on paper) of things about Python that you figured out (or confirmed) from those experiments. Rules about syntax (what you can say) and semantics (what it means to the interpreter). Put your names on it and hand it in.
print("Hi there person", "I think you are grand")
print(4)
print(4, 5, "six six six")
printzzz("Hi there person")
print(Hi there person)
print Hi there person
print(name)
name = "Bob"
print(name)
For this lab, you are going to write a Python program that interacts with a user at the command line. Instead of exectuing code statements at the interactive prompt, you are going to put your program in a file and run it all at once.
Write a sequence of Python statements (lines of code) in your file to implement this interaction with the user. (The program must stop to wait for the user to type their name and age).
Hello! What is your name? emmett And how old are you? 42 42 is a great age, emmett.
Test your code with multiple inputs and make sure it does what you think it should all the time!