Let's start learning to write Python with "Hello World program".
What is "Hello World Program"?
It is the first program in nearly every programming language for every programmer. It displays the words, "Hello World". It doesn't really print anything on the paper. In Python, it looks like this:
>>>print('Hello World')
After writing the code above in your program, click on run button.(click enter if you are using command promp). The result(which is called "output" in programming) is the words
Hello World
Note that the single quotation marks don't appear in the output. The computer displays only the words between them.
Exercise 1:In this tutorial, we write a program that prints Hello World. In this program, there is only a function. In Python, print() is the function which displays the words to the user. Now write a program that prints Please subcribe Python for everyone.
Exercise2 : Unlike the languages we speak, the details matter in programming languages. If you make mistake (e.g. leave out, or forget, the parenthese), the program gives you error messages but doesn't give you output. Make your own mistakes, learn from your mistakes and answer the following questions.
- What happens if you spell print wrong?
- What happens if you forget one of the parentheses, or both?
- What happens if you forget one of the single quotation marks, or both?
- What happens if you use double quotation marks("...") instead of single quotation marks('...')?
You will get error messages in Exercise2 Question no. 1,2 and 3. But you won't get any error massage in Question no.4? Is there any difference between double quotes and single quotes? When should single quote be used and when double quote? Please go on next tutorial for the answers.
Comments
Post a Comment