Skip to content
Zeni Study
  • Pages
    • Learn Python In 7 Days
      • icon picker
        Day 1 : Variable + if/else
      • Day 2: Loops
      • Day 3 : Array + String
      • Day 4 — Functions
      • Day 5 — Dictionaries - Hashmap
      • Day 6 — Files & Errors
      • Day 7 — Mini Project & Programmer Thinking
    • Machine Coding:
      • Day 1 — Bank account + Wallet :
      • Day 2 : RateLimiter + seat booking
      • Day 3 : Library Management + Classroom Attendance System
      • Day 4 : Bank account and notification system.
      • Day 5 : Key-value and payment processor.
      • Day 6 : Discount engine + Seat booking( in depth)
      • Day 7: Parking lot System :
    • Machine coding extended:
      • Day 7.5 — Parking Lot (Constraint-Heavy Variant)
      • Day 8 : Order + Payment System
      • Day 8 — Extension Round (Mid-Interview Change)
      • Day 9 — Ticket Booking with Expiry (Simulated Time)
      • Day 9 — Extension Round (Seat Lock Ownership + Forced Unlock)
    • SQL + DB Thinking course
      • Day 1 — Tables, Rows & Thinking in Data
      • Day 2 — Relationships & Foreign Keys (Thinking in Connections)
      • Day 3 — Filtering, Aggregation & Answering Data Questions
      • Day 4 — JOINs (Combining Tables the Right Way)
      • Day 5 — Subqueries, EXISTS & NOT EXISTS (Thinking in Layers)
      • Day 6 — Indexes, Constraints & How Databases Think
      • Day 7 — Full SQL Interview Simulation (SDE-1 Ready)
      • Extended Day 1 — Core Business Systems (Deep Practice)
      • Extended Day 2 — Booking & Platform Systems (High-Depth Practice)
      • Extended Day 3 — Content & Learning Platforms (Capstone Practice)
    • LLD: Java
      • DAY 1 — Core Foundations (SDE-2 Level)
      • DAY 2 — State, Time & Domain Correctness
      • DAY 3 — Extensibility & Failure Handling (SDE-2 Core Signal)
      • DAY 4 — Concurrency, Scheduling & Consistency (SDE-2 Critical)
      • DAY 5 — Workflow Design & Config-Driven Systems (SDE-2+)
      • DAY 6 — Eventing & Usage-Based Systems (Advanced SDE-2)
      • DAY 7 — Interview Simulation (Hard, Production-Grade)
      • Hidden Edge Cases Interviewers Expect (Day-wise)
      • Detailed Testing file:
    • Assignment:
      • If else Practice Set

Day 1 : Variable + if/else


🟢 Day 1 — Thinking Like a Computer (Foundations)

1️⃣ Why Are We Learning This?

Imagine you are talking to a very obedient but very dumb assistant.
It never guesses
It never assumes
It never understands meaning
It only follows exact instructions, step by step
That assistant is a computer.
💡 Programming = learning how to give clear, exact, unambiguous instructions
Python is just the language we use to talk to it.

2️⃣ How a Computer Thinks (Very Important)

A computer:
Reads code top to bottom
Executes one line at a time
Never skips lines
Never understands intent
Example (read carefully):
x = 10
x = 20
print(x)
👉 Output will be 20 Because the latest instruction wins.
🧠 A computer does not remember history. It only knows the current value.

3️⃣ Variables — Storing Information

Real-world analogy

Think of a labeled box.
Label = variable name
Value = what is inside the box
name → "Amit"
age → 22

Python example

name = "Amit"
age = 22

print(name)
print(age)

Important Rules

Variable names should describe the data
Python decides the type automatically
You don’t declare types like other languages

4️⃣ Data Types (Only What We Need Today)→ i love my wife

Numbers

x = 10 # integer
price = 99.5 # float

Text (String)

city = "Delhi"

Boolean (True / False)

is_active = True
🧠 Think of types as different kinds of boxes

5️⃣ Taking Input from User

So far, you are giving values.
Now let the user give values.
name = input("Enter your name: ")
print(name)

Important Truth (Critical for beginners)

input() always gives text, even if user types a number.
age = input("Enter age: ")
print(type(age)) # this is string, not number

Converting to number

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

6️⃣ Making Decisions — if / else

Real life example:
If traffic light is red → stop Else → go
Python works the same way.
age = int(input("Enter age: "))

if age >= 18:
print("Adult")
else:
print("Minor")

How computer evaluates this:

Check condition (age >= 18)
If True → run first block
If False → run else block
🧠 Computer does not know what “adult” means. It only checks true or false.

7️⃣ Indentation — Python’s Superpower

Python uses spaces, not brackets.
❌ Wrong
if age >= 18:
print("Adult")
✅ Correct
if age >= 18:
print("Adult")
🧠 Indentation tells Python which code belongs together

8️⃣ Common Beginner Mistakes (Read Carefully)

Forgetting to convert input to number
Using = instead of ==
Wrong indentation
Assuming computer “understands intention”
Example mistake:
if age = 18: # ❌ wrong
Correct:
if age == 18:

9️⃣ Practice Questions (Do These Seriously)

Do not jump to code immediately. Think first. Write steps on paper.

Q1

Print "Hello, Python" on the screen.

Q2

Store your name and age in variables and print them.

Q3

Take a number from user and print whether it is positive or negative.

Q4

Take a number and print whether it is even or odd.

Q5

Take two numbers and print the larger one.

Q6

Take age as input and print:
"Child" if age < 13
"Teen" if age between 13–19
"Adult" otherwise

Q7 (Thinking Question)

What happens if the user enters "abc" instead of a number? Why does the program crash?
(No fixing yet. Just observe.)

🔑 HINTS (Read Only If Stuck)

Use % operator to check even/odd
if, elif, else are mutually exclusive
Convert input using int()
Comparison operators: >, <, >=, <=, ==
Think in true / false, not English meaning

🔟 What You Should Be Able to Do Now

By end of Day 1, you should:
Understand how computer executes code
Store and update values
Take input from user
Make decisions using conditions
Predict output before running code

🧠 Reflection (VERY IMPORTANT)

Answer in words, not code:
Why does computer need exact instructions?
Why is input always a string?
What happens if indentation is wrong?
How does computer decide which block to run?

⭐ Golden Rule from Day 1

The computer is never wrong. Your instructions are.


 
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.