Introduction of Python Programming Language
Python is a simple, powerful, and beginner-friendly programming language created by Guido van Rossum. It is widely used because of its easy syntax, large community, and many useful libraries. Python can be used to build websites, automate tasks, create AI and machine learning applications, analyze data, develop games, improve cyber security, program smart devices (IoT), work in finance, and support education and research. The best way to learn Python is to understand the concepts, practice regularly, and build real-world projects.
Complete Python Setup Guide Vscode + Python
%20Arithmetics%20(1).png)
What is Python?
Python is a simple and beginner-friendly programming language used for web development, automation, AI, data science, and software development.
What is VS Code?
VS Code is a free code editor used to write, run, and debug Python programs.
Install Python
- Download Python from the official website. - Install it and enable Add Python to PATH. - Verify using "python --version".
Install VS Code
- Download and install VS Code. - Install the Python extension. - Select the Python interpreter.
Create and Run a Program
Python
print("Hello,World!")
- Create a ".py" file.
- Write and save your code.
- Run the program and check the output in the Terminal.
If you want to read the full guide on how to install Python and VS Code in detail, with images, click the button below.
Python Print Statement and Comments Explained with Examples
What is a print statement in Python?
A print statement Function is used to show output on the screen. In Python, we write print() with a small letter p, not a capital letter.
Example:
Python
print("Hello,World!")
Output (show in Terminal):
Terminal
Hello,World!
What is a comment in Python?
A comment is used to explain a line of code. In Python, a comment is written using #(hash) at the start of the line, and the shortcut key Ctrl + / can be used to add or remove comments,but comment doesn't show in output
Example:
Python
# print a I Love Python in python ----> is Called as Comments!
print("I Love Python!")
print(2+2)
Output (show in Terminal):
Terminal
I Love Python! 4
Python Variables and Data Types Explained with Examples
What is a Variable in Python?
A variable is a named container used to store data or information in a program. The stored data can be used, changed, or updated whenever the program runs.
What is a Data Types in Python?
A data type defines the type of value that can be stored in a variable.
Example:
Python
student_name="Ali"
roll_number=1
college_name="ABCD"
address="XYZ"
print("Student Name:",student_name)
print("Roll No:",roll_number)
print("College Name:",college_name)
print("Address:",address)
Output (show in Terminal):
Terminal
Student Name:Ali Roll No:1 College Name:ABCD Address:XYZ
Python Fundamental (int,float,str,bool) Data types Explained with Examples
What are Data Types?
Data Types define the type of value stored in a variable. Every variable in Python belongs to a specific data type.
Fundamental Data Types
| Data Type | Description | Example |
|---|---|---|
int |
Stores whole numbers (without decimal). | 10, -5, 100 |
float |
Stores decimal (floating-point) numbers. | 10.5, 99.99, 3.14 |
str |
Stores text or a sequence of characters. | "Hello", "Python" |
bool |
Stores only two values: True or False. |
True, False |
type() Function
Used to check the data type of a variable.
Python
print(type(variable))
String Quotes
A string can be written using:
Single Quotes ' '
Double Quotes " "
Multiple Quotes ''' '''
Boolean Values
A Boolean stores only two values:
True
False
f-String
Used to print text and variables together.
Python
print(f"My name is {name}")
Python Input & Output – Notes
1. Input & Output

Input is used to receive data from the user, while Output is used to display results on the screen. Python mainly uses input() and print() for Input and Output.
2. print() Function
The print() function is used to display text, numbers, variables, and results on the screen.
Python
print("Hello World")
3. input() Function
The input() function is used to take data from the user. By default, input() returns the entered data as a string.
Python
name = input("Enter your name: ")
4. Type Casting with Input
int() converts input into an integer (whole number), while float() converts input into a decimal number.
Python
age = int(input("Enter age: "))
price = float(input("Enter price: "))
5. Multiple Input
.split() divides one input into multiple values, while map() applies a conversion function to multiple values.
Python
a, b = map(int, input("Enter two numbers: ").split())
print("Sum:", a + b)
6. f-String
An f-string is used to easily display variables inside a string. Variables are written inside { }.
Python
print(f"Name: {name}, Age: {age}")
7. print() Parameters
sep sets the separator between multiple values.
Python
print("Date", "Month", "Year", sep="/")
end controls what is printed after the output.
Python
print("Hello", end=" ")
print("World")
8. Escape Sequences
In Python, \ is the escape character. Common escape sequences are used to perform special actions inside strings.
\n → New line
\t → Tab space
\\ → Backslash
\' → Single quote
\" → Double quote
Python
print("Hello\nWorld")
print("Name:\tHamid")
Comments
Post a Comment