The previous code puzzles were written with two coding languages, Block and Scratch, that teach children coding concepts. When programmers want to write an app or program, they use text-based coding languages, for example, Python. Our first code puzzle displayed the message “Hello world”, asked the user his or her name, and then displayed the name the user typed in.
Here is the same example written in Python.
How the code works
Here's the output.
- print("Hello world") prints the message Hello world!
- yourName is a variable. Variables hold values.
- yourName=input("What is your name?") asks you What is your name? The name you type in is stored in the variable yourName.
- print(yourName) prints the name you typed in.
Here's the output.