🏠 Home

🕵️ The Data Identity Detector

Objective: Build a program that identifies data types!

🚀 OPEN GOOGLE COLAB

(Click to open in a new tab)

🗝️ Key Concepts

📦 Variables: Boxes where we store information.
⌨️ input(): The function to get data FROM the user.
🔢 Data Types:
  • int (Integers/Whole numbers)
  • float (Decimals)
  • str (Text)
🔄 Casting: Converting one data type into another (e.g., text to number).

📘 Part 1: The "String Trap"

⚠️ THE GOLDEN RULE

The input() function ALWAYS receives information as Text (String), even if you type a number!

If you write:

age = input("How old are you?")

And the user types 15, Python sees "15" (text), NOT the number 15. To use it as math, you must CAST it.

💻 Part 2: Your Mission

Follow these steps in your Google Colab notebook:

Step 1: Setup

Create a new notebook and name it: Data_Types_Practice_YourName

Step 2: Capture Data

Create a variable named user_input. Use input() to ask the user to type something.

Step 3: Transformation Logic

Your code must try to "guess" the data type:

  1. Try to convert to int (Integer).
  2. If that fails, try float (Decimal).
  3. If that fails, keep it as str (String).

Step 4: Decision Logic

Use if, elif, and else to print the result.

Reminders:

  • Conditionals always end with a colon :
  • Indentation (spacing) is CRITICAL in Python!

💡 Code Structure Hint (Don't just copy!)

# 1. Ask for data raw_input = input("Type something: ") # 2. Logic to detect type try: final_value = int(raw_input) data_type = "Integer" except ValueError: # Try float... try: final_value = float(raw_input) data_type = "Float" except ValueError: # Must be string final_value = raw_input data_type = "String" # 3. Print Result print("Type is:", data_type)

📝 Code Submission

Paste your code from Google Colab here to check your score. (Note: Copy/Paste is disabled. You must type manually to verify your understanding!)

✅ Evaluation Criteria

  • Used the input() function correctly.
  • Code handles errors (uses try/except).
  • Identifies types (uses int(), float(), if/elif).
  • Added comments (#) explaining the code.
🏆

CERTIFICATE OF COMPLETION

This certifies that

Student Name

Has successfully built the
Data Identity Detector!

Python Path - Day 5