Exercise 1: A Good First Program
来源:互联网 发布:激光雕刻软件 编辑:程序博客网 时间:2024/05/21 05:41
The first program among programming language for beginner is Hello World program. You can print a string such as Hello World in this programming language.
Hello World in python is very simple.
All code is
print "Hello World"Then put the code into a single file named whatever you want, such as ex1.py.
Notice the file extension py, it's not required but recommended.
Now that you complete a python source code file, you can run it in the terminal like this
python ex1.pyYou can see the output Hello World.
If you have an error like this
$ python ex1.py File "ex1.py", line 1 print "Hello World. ^SyntaxError: EOL while scanning string literal
- Here we ran our command in the terminal to run the ex1.py script.
- Python then tells us that the file ex1.py has an error on line 1.
- It then prints this line for us.
- Then it puts a ^ (caret) character to point at where the problem is.Notice the missing" (double-quote) character?
- Finally, it prints out a "SyntaxError" and tells us something about what might be the error. Usually these are very cryptic, but if you copy that text into a search engine, you will find someone else who's had that error and you can probably figure out how to fix it.
Warning
If you are from another country, and you get errors about ASCII encodings, thenput this at the top of your python scripts:
# -- coding: utf-8 --
It will fix them so that you can use unicode UTF-8 in your scripts without a problem.
- Exercise 1: A Good First Program
- Lesson 1 A simple first program
- Learn Python The Hard Way 3: Ex01 A good first Program
- How To Make A Good Program
- 《算法》第四版 Your First Java Program: Hello World——exercise 记录
- A good program of the greedy snake game.
- How to Create a First C Program on Linux
- A good blog about how to write an Hadoop MapReduce program in Python
- Writing Your First Program
- My First RMI Program
- My First Java Program...
- The first QT Program !
- Your First OpenGL Program
- first program by c
- MY FIRST C++ PROGRAM
- first python program
- The first GTK+ Program
- my first java program
- 学习java多线程的笔记3-使用BlockingQueue阻塞队列来模拟两个线程之间的通信
- Servlet 之 生命周期
- 2012年安防事业的发展
- 安卓SharedPreferences用法
- 【状态压缩搜索】函数依赖
- Exercise 1: A Good First Program
- 作为一名大三学生,我是该选择Java还是C++?求救啦
- source insight 使用技巧
- c语言基础 二
- C++ 十进制'纯'小数转换为任意进制的小数
- asyncore的使用
- Re-installation failed due to different application signatures.解决方法
- ANDROID-Developing-tools-adb
- C#入门基础知识