Check Digit Count Type
Check whether a given integer is single-digit, double-digit, or multi-digit.
IntermediatePhase 1 - Level 3: Math and Number LogicExample 4 of 10
check-digit-count-type.py
1# Take number2num = abs(int(input("Enter a number: ")))34# Check digit count5if num < 10:6 print("Single-digit")7elif num < 100:8 print("Double-digit")9else:10 print("Multi-digit")
Output
Enter a number: 5 Single-digit Enter a number: 45 Double-digit Enter a number: 123 Multi-digit
What's going on
Use range checks to determine digit count.
Key Concepts:
Single-digit: 0-9 (< 10)
Double-digit: 10-99 (< 100)
Multi-digit: 100+ (>= 100)
Use abs() to handle negative numbers
🔗Related Content
- 📖
Phase 1 - Learn Concepts
Review Phase 1 concepts and explanations
- 📝
Phase 1 - Quiz
Test your Phase 1 understanding with quiz questions
- 💻
Phase 1 - All Practice Problems
Explore all practice problems for Phase 1
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum