What is Python
Python is a high-level, interpreted, object-oriented programming language. It is designed to be easy to read
and understand, and can be used for a wide variety of applications, from web development to data analysis to
game development. Python has a large and active community of developers, and many frameworks and
libraries available for use.
Programming Language
Structure Programming Language Object Oriented Programming Language
(OOP)
Things Event Real Object Software
B, I, U Click, Double
Object
Click
State variable
function
Behavior
Static Language (Java, C#, C, C++, Ruby)
Dynamic Language (JavaScript, PHP, Python)
Area
Windows Application
Web Application
Mobile Application
Open Python IDLE
Click Start Button and then click IDLE (Python 3.11) to open Python 3.11.2 Shell.
Open the Python Shell.
For open the Python Code Editor, Click File menu and choose New File (Ctrl+N).
Create Hello World Program
"print" statement is used to print the content.
Type the following code in Python Code Editor.
print ("Hello World")
To save the file, click File menu and choose Save (Ctrl+S).
When Save As Dialog box appear, choose Directory and assign the file name. (e.g., HelloWorld.py)
To run the program, click Run menu and choose Run Module (F5).
Display the result as shown below.
Python Escape sequence characters
Escape Sequence Description Example
’ Prints single-quote print “ \’ “
” Prints double-quote print “ \” “
\\ Prints backslash print “ \\ “
\n Linefeed print “\n”
\t Prints horizontal tab (TAB) print “\t”
Comments
Single line comment : #
Multi line comment : “”” (Three double quotation marks.)
Example (1)
print("hello \nworld")
print("K\tM\tD")
print("\"John\"")
print('\'Yangon\'')
print('\\Myanmar\\')
Example (2)
* *
* * *
* * * *
* * * * *
Example (3)
* *
* * *
* * * *
* * * * *
Example (4)
* * *
* * * * *
* * *
Example (5)
* * * * * * *
* *
* * * * * * *
Exercise
Write a Python program to print the following string in a specific format (see the output).