Page 33 - 2501_KVS_C-7
P. 33
Step 3: Click on File Menu Æ New
File option and write the
program and save file with
the .py extension.
Step 4: Now you can compile and
execute this program by
pressing F5 key. You will
get the result on the Python
shell.
3.1.2 Creating First Program
You have to create your first program, which will print "Hello World" on the screen.
To do this, type the following code:
# My first Program
print("Hello World")
Save the program and execute it. Python will give the following single-line output:
Hello World
You may notice that you wrote two lines of code but got one line of output—why is that?
This is because the # character marks a comment, and comments are ignored by the Python
interpreter when the program runs.
3.1.3 Understanding print() Function
print() function is used to display output.
Syntax: print(variable/message)
Example 1: Printing value
A=5
B=6
S=A+B
print(S) # here variable S is given and its value will be
printed.
You will get output as 11, because the value of S is 11.
Python Programming 31

