Friday, 3 April 2026

April Python Bootcamp Day 2



Most beginners think coding is hard…

But the truth?
It’s just about storing, understanding, and transforming data.

Today, you learned the foundation of Python — and this is where real programmers are built.


 1. What is a Variable?

A variable is like a container that stores data.

name = "Alice"
age = 25

👉 Here:

  • name stores a string
  • age stores a number

💡 Think of variables as labeled boxes where you keep information.


2. Data Types in Python

Python has different types of data:

🧩 Common Data Types

Data TypeExampleDescription
int10Whole numbers
float3.14Decimal numbers
str"Hello"Text
boolTrueTrue/False values

Example:

a = 10 # int
b = 3.5 # float
c = "Python" # string
d = True # boolean

3. Checking Data Type

Use type() to check:

x = 100
print(type(x))

👉 Output: <class 'int'>


4. Typecasting (Type Conversion)

Typecasting means converting one data type into another.

Examples:

x = "10"

# Convert string to integer
y = int(x)

# Convert integer to float
z = float(y)

# Convert number to string
s = str(z)

Important Note:

int("hello") # ❌ Error

👉 You can only convert compatible values.


Why Typecasting Matters?

  • Taking user input
  • Performing calculations
  • Formatting output

Example:

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

print(age + 5)

Real-Life Example

price = "100"
quantity = 2

total = int(price) * quantity
print("Total:", total)

Assignment (Practice Time )

 Basic Level

  1. Create variables:
    • Your name
    • Your age
    • Your favorite number
  2. Print their data types.

 Intermediate Level

  1. Take user input for:
    • Name
    • Age
  2. Convert age into integer and print:

    "Your age after 10 years will be: X"

Advanced Level

  1. Write a program:
# Input: price as string
# Input: quantity as int
# Output: total price

  1. Convert:
  • int → float
  • float → string
  • string → int

Print all results.


Bonus Challenge

  1. What will be the output?
x = "5"
y = 2
print(x * y)

👉 Explain why.

0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (119) AI (234) Android (25) AngularJS (1) Api (7) Assembly Language (2) aws (28) Azure (10) BI (10) Books (262) Bootcamp (2) C (78) C# (12) C++ (83) Course (87) Coursera (300) Cybersecurity (30) data (5) Data Analysis (29) Data Analytics (20) data management (15) Data Science (337) Data Strucures (16) Deep Learning (142) Django (16) Downloads (3) edx (21) Engineering (15) Euron (30) Events (7) Excel (19) Finance (10) flask (4) flutter (1) FPL (17) Generative AI (68) Git (10) Google (51) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (41) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (275) Meta (24) MICHIGAN (5) microsoft (11) Nvidia (8) Pandas (13) PHP (20) Projects (32) pytho (1) Python (1278) Python Coding Challenge (1118) Python Mistakes (50) Python Quiz (460) Python Tips (5) Questions (3) R (72) React (7) Scripting (3) security (4) Selenium Webdriver (4) Software (19) SQL (48) Udemy (18) UX Research (1) web application (11) Web development (8) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)