Python Programming Basic
📘 Python Basics Documentation
This document explains how to set up a Python file and
covers some of the foundational concepts such as data types, printing values,
comments, escape sequences, and variables.
🗂️ Creating a Python File
To start coding in Python, you need to create a `.py` file.
Here’s how to do it:
1. Create a folder (example: `pythonclass`) to store your
Python projects.
2. Inside that folder, right-click and choose:
New → Python File
Name your file (e.g.,
`first_script.py`).
🔢 Python Data Types
Python supports various data types. Below are some of the
basic ones:
1. Integer
Whole numbers without a decimal point.
print(10)
2. Floating Point / Decimal
Numbers with decimal points.
print(10.5)
3. String
A sequence of characters. Strings can be enclosed in either
single (`'`) or double (`"`) quotes.
print("Topu")
print('Topu')
💬 Comments in Python
Comments are notes in your code that Python ignores during
execution. They help others (and you) understand the code.
1. Single-line comment
Use the `#` symbol:
# This is my biodata
2. Multi-line comment
Use triple single quotes (`'''`) or triple double quotes
(`"""`) to write multi-line comments:
'''
This
Is
A
Multiple line
Comment
'''
🔁 Escape Sequences (Backslash Characters)
Escape sequences allow you to include special characters in
strings.
Examples:
print("Topu \n 0162933443") # \n adds a new line
print("Topu \t 0162933443") # \t adds a tab space
print("\"Sabbir Chowdhury\"") # \" lets you use double quotes
inside a string
print('\'Sabbir Topu\'') # \' lets you use single quotes
inside a string
Common Escape Sequences:
|
Escape Code |
Meaning |
|
\n |
New Line |
|
\t |
Tab Space |
|
\" |
Double Quote |
|
\' |
Single Quote |
🧠 Variables
Variables are used to store data that you can use later in
your program.
name = "Topu"
age = 25
print(name)
print(age)
This document provides the essential building blocks to begin your Python
journey. Practice each example to become comfortable with the syntax and
concepts.
Add comments here to make learning easier.
ReplyDelete