🚀 Day 4 of #100DaysOfCode Today I solved a Python problem to analyze a string and count different types of characters 🐍 🔍 Problem: Given a string, count the number of: ✔ Alphabets ✔ Digits ✔ Special Characters 💡 Approach: Iterate through each character in the string Use built-in methods like: 🔹 isalpha() for letters 🔹 isdigit() for numbers Count everything else as special symbols 🐍 Code: str1 = "P@#yn26at^&i5ve" alpha = 0 digit = 0 symbol = 0 for i in str1: if i.isalpha(): alpha += 1 elif i.isdigit(): digit += 1 else: symbol += 1 print(f"Alpha count = {alpha}") print(f"Digits count = {digit}") print(f"Symbol count = {symbol}") 📌 Output: Alpha count = 8 Digits count = 3 Symbol count = 4 📚 Key Learning: Built-in string functions in Python make problem-solving much easier and efficient. 💬 Consistency is the key — improving step by step every day 🔥 #Python #Coding #100DaysOfCode #Learning #CSE #Programming #Developers
Python String Character Counter with isalpha() and isdigit()
More Relevant Posts
-
Today I explored some advanced concepts in Python functions and variable scope that are super important for writing clean and scalable code 💻✨ 🔹 What I learned today: ✅ Default Arguments → Functions can have predefined values if no argument is passed ✅ Variable Length Arguments → *args → Non-keyword arguments (tuple) → **kwargs → Keyword arguments (dictionary) ✅ Functions, Modules & Libraries → Functions = reusable blocks → Modules = file of functions → Libraries = collection of modules ✅ Types of Variables in Python 🔸 Local Variables → Defined inside a function → Accessible only within that function 🔸 Global Variables → Defined outside functions → Accessible throughout the program 💡 Understanding these concepts helps in writing modular, reusable, and efficient code Consistency is key 🔥 Learning step by step, growing every day 💪 ✨ Write once, reuse everywhere with Python functions! Global Quest Technologies #Python #PythonLearning #Functions #VariableScope #CodingJourney #LearnToCode #Developers #TechSkills #Programming #GlobalQuestTechnologies
To view or add a comment, sign in
-
-
Hello connections 👋 Welcome to Day 3 of my Python problem-solving series! Consistency is the key to growth, so here is today’s challenge 🚀 🧠 Day 3 Challenge: Find Factorial of a Number The factorial of a number n is the product of all positive integers less than or equal to n. 👉 Example: Input: 5 → Output: 120 (5 × 4 × 3 × 2 × 1 = 120) My Approach: Using Loop num = int(input("Enter a number: ")) fact = 1 if num < 0: print("Factorial does not exist for negative numbers") else: for i in range(1, num + 1): fact *= i print("Factorial =", fact) 📌 Explanation: We multiply all numbers from 1 to num. Now it’s your turn 👇 Try solving it with your own logic or suggest a better approach in the comments. Let’s learn and grow together 🚀 #Python #CodingChallenge #ProblemSolving #Programming #30DaysOfCode
To view or add a comment, sign in
-
🚀 Day 8 of My Python Learning Journey Today, I built a Menu-Driven Calculator Program in Python 🧮 💡 What I learned & implemented: Creating functions (def) for reusable code Performing operations like Addition, Subtraction, Multiplication, Division, and Average Using conditional statements to control program flow Taking user input for dynamic calculations 🧠 Mini Project: Calculator Program I designed a calculator that allows users to: ✔ Select an operation from a menu ✔ Input numbers ✔ Get results instantly 📌 Functions Created: add() → Addition sub() → Subtraction multiply() → Multiplication (and more...) 🔍 Key Learning: Breaking a problem into smaller functions makes the code cleaner, reusable, and easier to manage. 💭 This is helping me build a strong foundation for writing scalable and structured programs. 🚀 Next Step: Loops & Advanced Logic Implementation https://lnkd.in/gJrKBVi3 #Python #LearningJourney #100DaysOfCode #Coding #DataAnalytics #Functions #ProblemSolving
To view or add a comment, sign in
-
Today I continued my Python functions practice and learned the remaining two important types. Type 3 — Without Arguments & With Return Theory: Function does not take parameters Takes input inside the function Returns the result to the caller Output is printed outside the function Use case: When a function acts like a small tool that collects data and gives back a result. def sum_digits(): n = int(input("Enter number: ")) s = 0 while n > 0: s += n % 10 n //= 10 return s print(sum_digits()) Type 4 — With Arguments & With Return Theory: Function takes input as parameters Does not take input inside Returns the result This type is used in interviews, and real projects Use case: Reusable logic that can be called multiple times with different values. def sum_digits(n): s = 0 while n > 0: s += n % 10 n //= 10 return s print(sum_digits(1234)) Key Learning Same problem can be written in different function types depending on the need. Understanding function design is more important than the problem itself. I’m improving my Python fundamentals step by step #Python #Programming #Learning #CodingJourney #Functions
To view or add a comment, sign in
-
🤯 This Python concept completely changed how I see functions… For the longest time, I thought functions were simple: 👉 You call them 👉 They run 👉 They forget everything Done. But then I discovered closures… and realized: 👉 Functions in Python can actually remember things. 🧠 Here’s the idea: A function can hold onto data from where it was created —even after that outer function is gone. That means: 👉 You’re not just writing functions 👉 You’re creating functions with memory 🔥 Why this matters: Once this clicked, I started to: ✔ Write cleaner code (no unnecessary globals) ✔ Understand decorators properly ✔ Think in terms of reusable logic blocks ✔ Feel more “Pythonic” in problem-solving 💡 The shift: Before: 👉 Functions = just execution After: 👉 Functions = execution + memory Most beginners skip this concept. Most developers don’t fully use it. But once you get it… you start writing better Python without even trying. 📌 I made a simple visual to explain closures — check it out above. Save it. Revisit it. It’ll click again later. #Python #Coding #Developers #LearnPython #Programming #SoftwareEngineering
To view or add a comment, sign in
-
-
🚨 Python Gotcha: “is” vs “==” (Most Students Confuse This!) This is one of the most common mistakes beginners make in Python — and it can silently break your logic. 🔍 What’s the difference? 👉 == → checks VALUE 👉 is → checks MEMORY LOCATION (identity) 💡 Example: a = [1, 2] b = [1, 2] print(a == b) # True print(a is b) # False ❌ unexpected 👉 Why this happens: Both lists have the same values, but they are stored in different memory locations. So: ✔ Values are equal ❌ Objects are not the same ✅ Correct Usage: x = None if x is None: print("Correct way to check None") ✅ 🧠 Key Takeaway: Use == when comparing values. Use is only when checking identity (especially for None). ❓ Have you ever used is incorrectly? #Python #Programming #CodingTips #PythonTips #Developers #LearnPython
To view or add a comment, sign in
-
-
54/75 Today I spent some time learning about asynchronous programming in Python and honestly, it changed how I think about performance. Instead of waiting for one task to finish before starting another, async lets your code handle multiple things at once. It’s especially powerful for I/O-heavy tasks like API calls, database queries, or web scraping. What stood out to me: • Faster execution without adding more hardware • Cleaner handling of concurrent operations • The power of async and await when used correctly It’s one of those concepts that feels confusing at first, but once it clicks, you start seeing so many real-world use cases. Still experimenting with it but definitely a step forward in writing more efficient systems 🚀 #Python #AsyncProgramming #LearningInPublic #SoftwareDevelopment
To view or add a comment, sign in
-
-
🚀 Understanding Armstrong Numbers in Python Today, I explored the concept of Armstrong Numbers and implemented a simple Python program to check whether a number satisfies this property. 🔍 What is an Armstrong Number? An Armstrong number is a number that is equal to the sum of its digits raised to the power of the total number of digits. 👉 Example: For 153 Digits → 1, 5, 3 Calculation → 1³ + 5³ + 3³ = 1 + 125 + 27 = 153 ✅ 💻 What this code does: Takes a number (e.g., 153) Extracts each digit using modulus and division Raises each digit to the power of total digits Adds the result to compute the sum Compares the sum with the original number Prints whether it is an Armstrong number or not 🧠 Key Concepts Used: While Loop Modulus Operator (%) Integer Division (//) Basic Mathematics Logic 📌 Learning Outcome: This small program helped me strengthen my understanding of: Number manipulation in Python Loop-based problem solving Writing clean logic for mathematical problems 💡 Next Step: Planning to extend this logic to check Armstrong numbers in a given range! #Python #Coding #100DaysOfCode #Programming #Learning #ComputerScience #Developers #CodingJourney
To view or add a comment, sign in
-
-
12 Python Dictionary Methods I Use Almost Every Day Dictionaries are everywhere in Python… But using them efficiently makes a real difference. These are some methods I rely on regularly: 1) get() → access keys safely (no KeyError). 2) items() → loop through key–value pairs easily. 3) update() → merge dictionaries cleanly. 4) pop() → remove a key and return its value. 5) popitem() → remove the last inserted pair. 6) keys() → quickly check available keys. 7) values() → inspect stored values. 8) fromkeys() → create dictionaries with default values. 9) in → fast key existence check. 10) len() → count total items. 11) clear() → reset dictionary safely. 12) dict() → simple and readable creation. From experience: Knowing these small methods well can make your code cleaner and faster to write. Comment below, Which dictionary method do you use the most? #Python #Programming #Coding #Developers #PythonTips #SoftwareEngineering #LearnPython
To view or add a comment, sign in
-
-
🚨 Python Tip: A Cleaner Way to Loop Most beginners write loops like this 👇 arr = [10, 20, 30] for i in range(len(arr)): print(i, arr[i]) ❌ Works… but not the best way ✅ Better & Pythonic way: arr = [10, 20, 30] for index, value in enumerate(arr): print(index, value) 🔍 Why this is better: ✔ Cleaner syntax ✔ More readable ✔ Less chance of errors ✔ Direct access to both index and value 🧠 Key Takeaway: Prefer enumerate() over range(len()) for looping through lists. Small improvement, big difference in code quality. ❓ Do you use enumerate() or still prefer range()? #Python #Programming #CodingTips #PythonTips #Developers #LearnPython
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
is posible to solve without using built in functions