Learn Python
Python Introduction |
Python Installation |
Python Hello World |
Python Tokens |
Python Program Structure |
Python Variables and Assignments |
Python Input Output |
Python Data Types |
Python Mutable Immutable |
Python Opeartors |
Python Expression |
Python if statement |
Python range method |
Python Loop |
Python break continue |
Python Loop else |
Python Nested Loop |
Python Hello World
Hello World is the most common output of any language. print( ) is used to print ...
Hello World in Python
A python program is called Script, It is a sequence of definitions and commands. These definitions are evaluated and commands are executed by the Python Interpreter, called Python Shell.
Python Syntax - refers to a set of rules that defines how users and the system should write and interpret a Python program.
Using print() method
>>> print(“Hello Programmer”)
Hello Programmer
>>> print(“Anjeev Singh welcomes you all”)
Anjeev Singh welcomes you all
>>> print(“In the world of Python Programming”)
In the world of Python Programming
>>> print(“Good Luck and Happy Programming”)
Good Luck and Happy Programming
print( ) is function which is used to display the specified content on the screen. The content called argument is specified within the parentheses.
print( ) statement without any argument simply jump to the next line. Arguments are written inside the double or single quote and separated by comma.
Syntax of print( )
print(values,..., sep=’ ’, end=’\n ’, file=sys.stdout, flush=False)
>>>print(10, 20, 30) // space is default separator and ‘\n’ is the default end value.
10 20 30
>>> print(10, 20, 30, sep=’*’)
10*20*30
>>>print(“Anjeev”, “Singh”, “Academy”, sep=”-*-“)
Anjeev-*-Singh-*-Academy
>>>print(“Anjev”,Singh”, sep=”#” end=”@Academy”)
Anjeev#Singh@Academy
Python/IDLE as Calculator
Python has rich set of operators, like text/string message, we can also perform mathematical calculation using the Python command prompt [in Interactive Mode]. You can do it by typing the command directly at prompt and by using print( ) method.
>>> 5 + 10
15
>>> 3.14 * 2 * 2
12.56
>>> 20/4 * 9 + 6 – 12
39
>>> print( 10+20)
30
>>> print(15/3*2-3)
7
>>> print(3.14 * 2 * 2)
12.56
"To repeat the same command in Interactive Mode IDLE, press Alt + P or move the cursor in the same line and press Enter Key.
Exiting Python [IDLE]
Type quit() or exit() function and press Enter Key.
>>> exit()
>>> quit()
