Hello World in Karel

Our first program will print the classic “hello world” message. Here’s the full source code.

def main():
    print("hello world")

if __name__ == "__main__":
    main()

To run the program, save the code in a file named hello-world.py and use the Python interpreter to execute it.

$ python hello-world.py
hello world

In Python, we generally do not need to build our programs into binaries. Instead, we distribute the script files directly or package them into archives.

Now that we can run and build basic Python programs, let’s learn more about the language.

Next example: Values.

查看推荐产品

Comments powered by Disqus