Python HelloFriend Guide
The is a Helloworld tutorial for python. Follows the following steps to learn the fundamental of Python input and output:
1. create a folder to store your source code, for example:
mkdir -p ~/source/python/HelloFriend/src
2. change the current directory to the working folder, for example:
cd ~/source/python/HelloFriend
3. create the source code by the following command:
nano src/HelloFriend.py
4. In the nano environment, type the source code:
#!/usr/bin/python def hello_friend(): name='' while True: name=raw_input("What is your name (type 'quit' to quit) ? ").strip() if name.lower()=='quit': break print 'Hello, '+name+'!' hello_friend()
5. press ctrl-x to leave and save the source code
6. Grant the Execution right to the python file:
chmod +x src/*.*
7. Run the program by the following command:
src/HelloFriend.py
8. As you run the program, you’ve been asked for your name repeatedly:
What is your name (type 'quit' to quit) ? Peter Pan Hello, Peter Pan! What is your name (type 'quit' to quit) ? quit