LEARN COMPLETE PYTHON IN 24 HOURS
🟦 Python Basics
🔹 1. Introduction to Python
1.1 What is Python and Why Learn It in 2025?
1.2 Who Uses Python Today?
1.3 Python vs Other Languages
1.4 How to Install Python
1.5 Setting Up VS Code
🔹 2. Basic Building Blocks
🔹 3. Operators in Python
🔹 4. Taking Input & Output
🔹 5. Control Flow (if-else)
🔹 6. Loops in Python
🔹 7. Lists
🔹 8. Tuples
🔹 9. Strings (Deep Dive)
🔹 10. Dictionaries
🔹 11. Sets
🔹 12. Functions
🔹 13. Modules & Packages
🔹 14. Mini Projects
2. Basic Building Blocks
These are the foundational elements of Python programming. Once you understand them, you can start building real programs!
2.1 Variables and Data Types
Variables are like containers that store data (values). In Python, you don't need to declare the type — it's dynamically typed (Python figures it out automatically).
Syntax to create a variable:
Python
variable_name = value
Rules for variable names:
Start with letter (a-z, A-Z) or underscore (_)
Can contain letters, numbers, underscore
Case-sensitive (age ≠ Age)
Cannot be Python keywords (like if, for, print)
Examples:
Python
# Valid variables name = "Anshuman" # string age = 25 # integer height = 5.9 # float is_student = True # boolean _marks = 98 # starts with underscore (ok) # Invalid examples (will give error) # 1age = 20 # starts with number # my-name = "Test" # has hyphen
Main Data Types in Python (built-in):
int → Whole numbers (e.g., 5, -100, 0)
float → Decimal numbers (e.g., 3.14, -0.5)
str → Text/strings (e.g., "Hello", 'Python')
bool → True or False
complex → Complex numbers (e.g., 3+4j) — used in math/science
Python also has more advanced types like list, tuple, dict, set (covered later).
Quick example program:
Python
name = "Anshuman" age = 25 height = 5.7 is_learning = True print("My name is", name) print("I am", age, "years old") print("Height:", height, "feet") print("Learning Python? Yes!", is_learning)
Output:
text
My name is Anshuman I am 25 years old Height: 5.7 feet Learning Python? Yes! True
Tip: Use meaningful names like total_price instead of x — makes code easier to read!
2.2 Numbers (int, float, complex)
Python handles numbers very easily.
int (Integer): Unlimited size (no overflow like in some languages).
Python
a = 100 b = -45 big_number = 12345678901234567890 # very large – no problem! print(a + b) # 55 print(a * 10) # 1000
float (Floating point): Decimals with approximate precision.
Python
pi = 3.14159 temperature = -2.5 print(pi * 2) # 6.28318
complex (Complex numbers): Used in engineering/math (real + imaginary part).
Python
c = 3 + 4j print(c) # (3+4j) print(c.real) # 3.0 print(c.imag) # 4.0 print(c.conjugate()) # (3-4j)
Common Operations:
Python
x = 10 y = 3 print(x + y) # 13 addition print(x - y) # 7 subtraction print(x y) # 30 multiplication print(x / y) # 3.333... division (always float) print(x // y) # 3 floor division (integer result) print(x % y) # 1 remainder (modulo) print(x * y) # 1000 power (x to the power y)
Tip: // is useful for integer results, % for checking even/odd (num % 2 == 0 → even).
2.3 Strings – Everything You Need to Know
Strings are sequences of characters (text). Defined using single quotes ' ' or double quotes " ".
Basic examples:
Python
greeting = "Hello, World!" name = 'Anshuman' multi_line = """This is a multi-line string in Python!""" print(greeting) # Hello, World! print(multi_line)
String Concatenation (joining):
Python
first = "Hello" second = "Python" print(first + " " + second) # Hello Python print(first * 3) # HelloHelloHello
f-strings (Best way – Python 3.6+): Super easy formatting!
Python
name = "Anshuman" age = 25 print(f"My name is {name} and I am {age} years old.") # My name is Anshuman and I am 25 years old.
Escape Characters: Use \ for special characters.
Python
print("He said, \"Python is fun!\"") # quotes inside print("Line1\nLine2") # new line print("Tab\tHere") # tab space print("Backslash \\") # print backslash
String Length & Access:
Python
text = "Python" print(len(text)) # 6 print(text[0]) # P (first character) print(text[-1]) # n (last character) print(text[1:4]) # yth (slicing: from index 1 to 3)
Tip: Strings are immutable — you can't change a character directly (e.g., text[0] = 'J' → error).
2.4 Boolean (True / False)
Booleans represent truth values — only two possibilities: True or False.
Used heavily in conditions/loops (later sections).
Python
is_adult = True has_python = False print(is_adult) # True print(type(is_adult)) # <class 'bool'> # Comparisons give booleans print(10 > 5) # True print(5 == 10) # False print("a" != "b") # True
Boolean from other types:
Empty string/list → False
Non-empty → True
0 → False, non-zero → True
Python
print(bool(0)) # False print(bool(100)) # True print(bool("")) # False print(bool("hi")) # True
2.5 type() function and Type Conversion
type() tells you the data type of any value/variable.
Python
x = 42 print(type(x)) # <class 'int'> y = 3.14 print(type(y)) # <class 'float'> z = "Hello" print(type(z)) # <class 'str'>
Type Conversion (Casting): Convert one type to another.
Python
# str → int num_str = "100" num = int(num_str) print(num + 50) # 150 # int/float → str age = 25 print("Age: " + str(age)) # Age: 25 # float → int (removes decimal) price = 99.99 print(int(price)) # 99 # str → float height = "5.7" print(float(height)) # 5.7
Common conversions:
int() → to integer
float() → to float
str() → to string
bool() → to boolean
Warning: Invalid conversion gives error, e.g., int("hello") → ValueError.
2.6 Comments in Python (# and multiline)
Comments explain your code — ignored by Python.
Single-line comment:
Python
# This is a single-line comment print("Hello") # This prints Hello (inline comment)
Multi-line comments: Use triple quotes (technically a string, but unused → acts as comment)
Python
""" This is a multi-line comment. You can write many lines here. Useful for explaining functions or sections. """ # OR use # on each line # Line 1 # Line 2
Best Practice:
Use comments to explain why (not what the code does)
Keep code self-explanatory with good variable names
Use docstrings (triple quotes) inside functions/classes later
Example with comments:
Python
# Program to calculate area of rectangle length = 10 # length in cm width = 5 # width in cm area = length * width # calculate area print(f"Area of rectangle: {area} sq cm") # output result
Output:
text
Area of rectangle: 50 sq cm
📚 Amazon Book Library
All my books are FREE on Amazon Kindle Unlimited🌍 Exclusive Country-Wise Amazon Book Library – Only Here!
On GlobalCodeMaster.com you’ll find complete, ready-to-use lists of my books with direct Amazon links for every country.
Belong to India, Australia, USA, UK, Canada or any other country? Just click your country’s link and enjoy:
✅ Any eBook FREE on Kindle Unlimited ✅ Or buy at incredibly low prices
400+ fresh books written in 2025-2026 with today’s latest AI, Python, Machine Learning & tech trends – nowhere else will you find this complete country-wise collection on one platform!
Choose your country below and start reading instantly 🚀
BOOK LIBRARY USA 2026 LINK
BOOK LIBRARY INDIA 2026 LINK
BOOK LIBRARY AUSTRALIA 2026 LINK
BOOK LIBRARY CANADA 2026 LINK
BOOK LIBRARY UNITED KINGDOM 2026 LINK
BOOK LIBRARY GERMANY 2026 LINK
BOOK LIBRARY FRANCE 2026 LINK
BOOK LIBRARY ITALY 2026 LINK
BOOK LIBRARY SPAIN 2026 LINK
BOOK LIBRARY NETHERLANDS 2026 LINK
BOOK LIBRARY BRAZIL 2026 LINK
BOOK LIBRARY MEXICO 2026 LINK
BOOK LIBRARY JAPAN 2026 LINK
BOOK LIBRARY POLAND 2026 LINK
BOOK LIBRARY IRELAND 2026 LINK
BOOK LIBRARY SWEDEN 2026 LINK
BOOK LIBRARY BELGIUM 2026 LINK
Email-ibm.anshuman@gmail.com
© 2026 CodeForge AI | Privacy Policy |Terms of Service | Contact | Disclaimer | 1000 university college list|book library australia 2026|Latest AI Trends (Global & India 2026) 400 GLOBAL BOOK STORE WORLDWID|TOP 400 FREE BOOK LIBRARY USA|TOP 400 FREE BOOK LIBRARY INDIA|Audiobooks at Just ₹99 | $1.25| E-Books at Just ₹49 | $0.50| 50+ AI Expert Tutorials
All my books are exclusively available on Amazon. The free notes/materials on globalcodemaster.com do NOT match even 1% with any of my PUBLISHED BOoks. Similar topics ≠ same content. Books have full details, exercises, chapters & structure — website notes do not.No book content is shared here. We fully comply with Amazon policies.
🚀 Best content for SSC, CGL, LDC, TET, NET & SET preparation!
📚 Maths | Reasoning | GK | Previous Year Questions | Tips & Tricks
👉 Join our WhatsApp Channel now:
🔗 https://whatsapp.com/channel/0029Vb6kg2vFnSz4zknEOG1D...