Learn to Code Python For Beginners

learn to code python
You are currently viewing Learn to Code Python For Beginners
learn to code python

Learn to Code Python For Beginners

Welcome to this blog, where we will Learn to code Python from scratch. This blog will contain tutorials in the form of lessons, notes, and videos.

Learn to Code Python – Part 1 – Basics

📘 Section 1: What is Python and Programming?

💡 Programming

Programming means giving step-by-step instructions to a computer to perform a task — like telling a robot what to do.

💡 Python

Python is a simple and powerful programming language used in web development, data science, automation, and more.


⚙️ Section 2: Setting Up Python

✅ Step 1: Install Python

You need Python installed to write and run your code. Download it from python.org.

✅ Step 2: Install VS Code

VS Code is a code editor where you write Python scripts. It makes coding easier with suggestions, error checks, and a terminal.


🧠 Section 3: Python Basics

📌 Data Types

Python has different types of data, just like real life:

TypeExamplePython Name
Text"hello"str
Number24int
Decimal59.7float
True/FalseTrue or Falsebool

📌 Variables

Variables are containers to store data.

name = "Kunal"
age = 24
is_married = False

Think of a cup holding water – the cup is the variable, and the water is the data.


🧪 Section 4: Type, Input, and Conversion

📌 type() Function

This shows what type of data a variable has.

print(type(name))  # str
print(type(age)) # int

📌 Getting User Input

We can ask users questions and store their answers.

name = input("What is your name? ")

🔁 Section 5: Data Conversion and F-Strings

📌 Type Conversion

Sometimes we need to change data from one type to another.

age = int(input("Enter your age: "))

📌 f-Strings

This is a cool way to write dynamic messages:

name = "Kunal"
age = 24
print(f"My name is {name} and I am {age} years old.")

🧮 Section 6: Lists and Operators

📌 Operators in Python

Operators are used to perform calculations:

SymbolMeaningExample
+Addition2 + 3 = 5
-Subtraction5 - 2 = 3
*Multiplication3 * 2 = 6
/Division6 / 3 = 2.0
//Floor Division7 // 2 = 3
%Modulus7 % 2 = 1

📌 Lists

A list is a collection that can store multiple values:

fruits = ["apple", "banana", "mango"]
print(fruits[0]) # apple

Lists can even store different data types.


🧠 Recap of What You’ve Learned in Part 1:

  • What programming is and why Python is a great choice
  • How to install Python and VS Code
  • Variables and Data Types
  • Checking data types using type()
  • Taking user input
  • Converting data types
  • Using f-strings for clean output
  • Working with lists and operators

Learn to Code Python – Part 2 – Operators

Welcome back, future Python masters! 👋 In Part 1 of our Python journey, we learned the basics — variables, data types, user input, and printing values. Now, it’s time to unlock the real power of Python by mastering operators.

In this post, we’ll break down operators step-by-step with simple examples, real-life analogies, and mini challenges to help you understand and apply them confidently.


🧠 What Are Operators?

Operators are symbols used to perform operations on values and variables.
Think of them like calculator buttons — they help you do math, compare values, and more.


🧮 Lesson 1: Arithmetic Operators

Operators Covered: +, -, *, /

These are basic math operations used in almost every program.

x = 20
y = 4

print(x + y) # 24
print(x - y) # 16
print(x * y) # 80
print(x / y) # 5.0

📌 Output:

24
16
80
5.0

🔢 Lesson 2: Floor Division and Modulus

Operators Covered: //, %

  • // → Returns only the whole number part (floor division)
  • % → Gives the remainder after division (modulus)
print(7 // 2)   # 3
print(7 % 2) # 1

📌 Output:

3
1

🧃 Example: Sharing 7 chocolates with 2 friends — each gets 3, and 1 is left.


⚡ Lesson 3: Power Operator

Operator Covered: **

Used for exponentiation — multiplying a number by itself multiple times.

print(2 ** 3)   # 8 (2×2×2)
print(5 ** 2) # 25 (5×5)

📌 Output:

8
25

🎯 Try It: Calculate the cube of a number using **.


🤝 Lesson 4: Comparison Operators

Operators: ==, !=, >, <, >=, <=

These return True or False when comparing values.

a = 10
b = 20

print(a == b) # False
print(a < b) # True

📌 Output:

False
True

Use them in conditions — like checking age for voting eligibility.


📦 Lesson 5: Assignment Operators

Operators: =, +=, -=, *=, /=

These update variable values in short form.

x = 10
x += 5
print(x) # 15

x *= 2
print(x) # 20

📌 Output:

15
20

🍜 Analogy: Like adding more food to your plate without changing plates.


🔐 Lesson 6: Logical Operators

Operators: and, or, not

Used for combining conditions in if statements or filters.

a = True
b = False

print(a and b) # False
print(a or b) # True
print(not a) # False

📌 Output:

False
True
False

Logical AND (and)

condition_1condition_2condition_1 and condition_2
TrueTrueTrue
TrueFalseFalse
FalseTrueFalse
FalseFalseFalse

Logical OR (or)

condition_1condition_2condition_1 or condition_2
TrueTrueTrue
TrueFalseTrue
FalseTrueTrue
FalseFalseFalse

Logical NOT (not condition_1)

condition_1not condition_1
TrueFalse
FalseTrue

Try this:

age = 18
is_student = True
print(age > 17 and is_student) # True

🧬 Lesson 7: Identity & Membership Operators

Operators: is, is not, in, not in

  • is: Checks if two variables point to the same object in memory.
  • in: Checks if a value exists in a list, string, etc.
a = [1, 2, 3]
b = a

print(a is b) # True
print(2 in a) # True

📌 Output:

True
True

🧮 Lesson 8: Operator Precedence

Like BODMAS in math, Python follows an order of operations.

print(2 + 3 * 4)     # 14
print((2 + 3) * 4) # 20

📌 Output:

14
20

🎯 Always use parentheses () to control execution order clearly.

Python Equivalent of PEMDAS

Python uses the same basic math precedence rules:

PEMDASPython EquivalentExample
P() Parentheses(2 + 3) * 4 → 20
E** Exponentiation2 ** 3 → 8
MD*, /, //, %10 / 2 * 3 → 15.0
AS+, -10 - 2 + 1 → 9

📌 Note: Multiplication/Division and Addition/Subtraction are evaluated left to right, depending on which comes first.


🧪 Lesson 9: Mini Python Calculator (Project)

Let’s combine all your knowledge and build a simple calculator.

a = 10
b = 5
op = '*'

if op == '+':
print(a + b)
elif op == '-':
print(a - b)
elif op == '*':
print(a * b)
elif op == '/':
print(a / b)

📌 Output:

50

🎯 Try replacing op = '*' with other operators and see the results.

Kunal Lonhare

I am the founder of Kuku Courses