Absolutely!
Below are your final Python Quick Revision Notes in a simple, clean format
(no W3Schools features, no run buttons, no special IDs). This is ideal for revision and easy
copying into Word or PDF.
🐍 Python Quick Revision Notes
1. What is Python?
Python is an interpreted programming language.
Python files are saved with the .py extension.
2. Python Installation
Check if Python is Installed
Windows / Linux / Mac
Bash
python --version
Example Output
Python 3.12.5
3. Run Python Code
Interactive Mode
Start Python:
Bash
python
Write:
Python Run
print("Hello, World!")
Output
Hello, World!
Exit Python:
Python Run
exit()
Run a Python File
Create [Link]
Python Run
print("Hello, World!")
Run:
Bash
python [Link]
Output
Hello, World!
4. Print Output
Print Text
Python Run
print("Hello World!")
Output
Hello World!
Print Multiple Lines
Python Run
print("Hello")
print("Python")
Output
Hello
Python
Single & Double Quotes
Python Run
print("Hello")
print('Hello')
Output
Hello
Hello
Wrong:
Python Run
print(Hello)
Output
NameError
Print Without New Line
Python Run
print("Hello", end=" ")
print("World")
Output
Hello World
Print Numbers
Python Run
print(3)
print(500)
Output
3
500
Print Math
Python Run
print(3 + 3)
print(2 * 5)
Output
6
10
Mix Text and Numbers
Python Run
print("Age:", 35)
Output
Age: 35
5. Python Version in Program
Python Run
import sys
print([Link])
Example Output
3.12.5 (...)
6. Indentation (Very Important)
Python uses indentation to define code blocks.
Correct:
Python Run
if 5 > 2:
print("Five is greater")
Output
Five is greater
Wrong:
Python Run
if 5 > 2:
print("Five is greater")
Output
IndentationError
Rules
Standard indentation = 4 spaces
Same block = Same indentation
7. Comments
Single-Line Comment
Python Run
# This is a comment
print("Hello")
Output
Hello
End-of-Line Comment
Python Run
print("Hello") # Comment
Output
Hello
Disable Code
Python Run
# print("Hello")
print("World")
Output
World
Multiline Comment
Python Run
# Line 1
# Line 2
# Line 3
or
Python Run
"""
Line 1
Line 2
Line 3
"""
Note: Python has no official multiline comment syntax. Using multiple # is recommended.
8. Variables
Create Variables
Variables are created when a value is assigned.
Python Run
x = 5
name = "John"
print(x)
print(name)
Output
5
John
Python does not require variable declaration.
Change Type
Python Run
x = 4
x = "Sally"
print(x)
Output
Sally
Check Type
Python Run
x = 5
print(type(x))
Output
<class 'int'>
Type Casting
Python Run
x = str(3)
y = int(3)
z = float(3)
print(x)
print(y)
print(z)
Output
3
3
3.0
Common Data Types
Type Example
int 5
float 3.14
str "Hello"
bool True
Case Sensitive
Python Run
a = 5
A = "John"
print(a)
print(A)
Output
5
John
a≠A
9. Variable Names
Rules
Start with a letter or _
Can contain letters, numbers and _
Cannot start with a number
No spaces
No hyphen ( - )
Cannot be a Python keyword
Variable names are case-sensitive
Valid
Python Run
my_var
myVar
_my_var
myvar2
Invalid
Python Run
2myvar
my-var
my var
Naming Styles
Camel Case
Python Run
myVariableName
Pascal Case
Python Run
MyVariableName
Snake Case (Recommended)
Python Run
my_variable_name
10. Multiple Assignment
Multiple Values
Python Run
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
Output
Orange
Banana
Cherry
Same Value
Python Run
x = y = z = "Orange"
print(x)
print(y)
print(z)
Output
Orange
Orange
Orange
Unpacking
Python Run
fruits = ["apple", "banana", "cherry"]
x, y, z = fruits
print(x)
print(y)
print(z)
Output
apple
banana
cherry
11. Output Variables
Print Variable
Python Run
x = "Python"
print(x)
Output
Python
Multiple Variables
Python Run
x = "Python"
y = "is"
z = "awesome"
print(x, y, z)
Output
Python is awesome
Join Strings
Python Run
x = "Python "
y = "is "
z = "awesome"
print(x + y + z)
Output
Python is awesome
Add Numbers
Python Run
x = 5
y = 10
print(x + y)
Output
15
String + Number ❌
Python Run
x = 5
y = "John"
print(x + y)
Output
TypeError
Use:
Python Run
print(x, y)
Output
5 John
12. Global Variables
Global Variable
A variable created outside a function is called a global variable.
Global variables can be used inside and outside functions.
Python Run
x = "awesome"
def myfunc():
print("Python is " + x)
myfunc()
Output
Python is awesome
Local Variable
A variable created inside a function is called a local variable.
It can only be used inside that function.
Python Run
x = "awesome"
def myfunc():
x = "fantastic"
print("Python is " + x)
myfunc()
print("Python is " + x)
Output
Python is fantastic
Python is awesome
Remember
Inside function → Local variable
Outside function → Global variable
Local variable does not change the global variable.
global Keyword
Create Global Variable Inside Function
Python Run
def myfunc():
global x
x = "fantastic"
myfunc()
print("Python is " + x)
Output
Python is fantastic
Modify Existing Global Variable
Python Run
x = "awesome"
def myfunc():
global x
x = "fantastic"
myfunc()
print("Python is " + x)
Output
Python is fantastic
Quick Comparison
Type Created Where? Accessible Where?
Global Variable Outside function Everywhere
Local Variable Inside function Inside that function only
Easy Memory Trick 🏠
Outside function = Global (Whole House)
Inside function = Local (One Room Only)
global keyword = Key that allows the function to access/change the whole house
variable
Important Commands
Task Command
Check installation python --version
Start Python shell python
Exit shell exit()
Run Python file python [Link]
Print output print()
Comment # Comment
Check type type()
Type conversion int() , float() , str()
Global variable global
Memory Flow 🚀
Install Python → Check Version → Run Python → Print Output → Comments →
Indentation → Variables → Variable Names → Multiple Assignment → Output
Variables → Global Variables → Run Program
These are your final approved notes, kept in a clean, simple format without any
interactive features or special UI.