0% found this document useful (0 votes)
29 views11 pages

Colledge of Science and Technology: ITE201: Python Programming

Uploaded by

Pech Channary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views11 pages

Colledge of Science and Technology: ITE201: Python Programming

Uploaded by

Pech Channary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Colledge of Science and Technology

ITE201: Python Programming


Part 2 - Basic of Python

Lecturer: DAN Tangoun


Run Python: using command

1. Open “Command prompt” (Windows) / Terminal (MacOS)


2. Type python or python3
3. Type print("Hello Python world!")

You will get the result:


Run Python: using file
1. Create a text file with extension .py (Example, hello_world.py)
2. Type print("Hello Python world!") in file hello_world.py
3. Go to file directory in Command Prompt or Terminal
4. Type python hello_world.py
(Example,the location of file is in C:\Users\Administrator\Desktop)
Run Python: using Jupiter notebook
• The Jupyter Notebook is an open-source web application
• Good for sharing python code (Export)
• Good visualization in note/comment on code (formatted text,
image, video,..)
• Editable code and update result
Rule for Python Syntax

✓ Python is case-sensitive
▪ name is not the same as Name (different Capital letter)
✓ Line indentation (No Curly Braces {…} ) indicates grouping of
statements
▪ Some other program use {…} for block of code or grouping but
Python use Indent
▪ Semicolon ; is optional (for ending a statement of code)

a = 10
if a<20:
print("a is less than 20")
else:
print("a is greater than 20")
✓ Multiline Statements
▪ Python does not allow to break statement normally by pressing
enter
▪ Use backslash ( \ ) for break the line of code for a statement.
Comment in Python
✓ Comment is ignored when processing the code
✓ Comment is useful for providing explanation for specific part of code
✓ Comment is useful for skip some parts of the code
✓ Comment is useful to find errors

✓ Use this symbol for comment: #

You might also like