Welcome to Day 2 of 100 Days of Code (Python)!
Today you’ll master Type Errors, Type Checking with type(), and Type Conversion/Casting using int(), float(), str(), and bool(). We’ll demystify why len(123) throws a TypeError and how to fix it, plus practical tips from IDE hints to Python docs.
What you’ll learn
Why len() expects a Sized object (e.g., string/list) and fails on int
IDE hints (e.g., PyCharm: hover to see expected types)
Type checking with type("Hello"), type(42), type(3.14), type(True)
Casting: when to use int(), float(), str(), bool()—and when it fails
Common pitfalls: "123" + "456" (concat) vs int("123")+int("456") (math)
Practice / Pause exercises
Fix the len() call by passing a string (e.g., "Hello")
Print the types of a string, int, float, and boolean
Challenge: Ask the user’s name and print:
Number of letters in your name: X (convert len(name) to str first!)
python typeerror, len typeerror python, python type checking, python type function, python casting, int() float() str() bool(), python concatenate vs add, python beginners day 2, 100 days of code python, python data types
Python,Python Tutorial,Python for Beginners,100 Days of Code,Day 2,TypeError,Type Checking,type(),Type Conversion,Casting,int(),float(),str(),bool(),len(),Concatenation vs Addition,Beginners,Programming Tutorial,Learn Python,Python Exercises
Информация по комментариям в разработке