Pyramids in Python print('\nNormalPyramid')for i in range(5): x='*' x=x*i print(f'{x:^10}')print('\nInvertPyramid\n')for i in range(5): x='*' x=x*(5-i) print(f'{x:^10}')print('Left sided Pyramid')rows = 5for i in range(1, rows + 1): stars = '*' * i print(f'{stars:<10}')print('\nRightsidedPyramid') rows = 5for i in range(1, rows + 1): spaces = ' ' * (rows - i) stars = '*' * i print(f'{spaces}{stars}')#pythoncode
Creating Pyramids with Python Code Examples
More Relevant Posts
-
Copying vs Reference 🐍 I thought this would create a copy: b = a It didn’t. a = [1, 2, 3] b = a b.append(4) print(a) 👉 [1, 2, 3, 4] Both variables point to the same list. No copy was made. In Python, variables are just labels, not containers. When you use =, you aren’t duplicating data, you’re just giving the same memory address a second name. To actually copy: b = a.copy() Looks the same. Behaves completely differently. 💡 And also: .copy() only goes one layer deep and that's why we need deep copy. ➡️ Assignment ≠ Copy Day 17/30 #Python #30DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
-
Unlocking the Power of Strings in Python! 🐍✨ Today’s focus on my Python journey was all about understanding and manipulation—specifically, Strings. It’s incredible how much logic depends on effectively handling text data! Here are my key takeaways from today's deep dive: ✂️ String Slicing: Mastering the [start:stop:step] syntax. It feels like precision surgery for text data—extracting exactly what you need, whether it's a prefix, a suffix, or a reversed substring. 🚫 String Immutability (Mutation): A crucial realization! You can’t change a string in place. Trying to do word[0] = 'C' will throw an error. Understanding this forces you to think correctly about creating new modified strings instead of trying to mutate existing ones. 🛠️ String Methods: My toolbox just got a lot bigger. I explored powerful built-in functions like: .strip() for cleaning up whitespace. .replace() for quick swaps. .split() and .join() for converting between strings and lists. .upper(), .lower(), .capitalize() for formatting. Understanding these fundamentals is making my code cleaner and more efficient. Every day is a step closer to building complex applications! #Python #CodingJourney #Strings #DataManipulation #SoftwareDevelopment #ContinuousLearning #WebDev #Backend #ProgrammingFundamentals #CleanCode #LearningToCode
To view or add a comment, sign in
-
-
Most implementations of the State pattern in Python look very “clean”. Lots of small classes. A base interface. One class per state. But if you’ve ever worked with one in a real project, you know the downside: transitions are scattered, behaviour is hard to see in one place, and adding new states often means touching multiple files. In today’s video, I rebuild the State pattern in a very different way. Instead of relying on inheritance, I make the state machine explicit as data and use decorators to define transitions. The result is a small, reusable engine where the entire flow becomes visible at a glance. If you’re interested in writing Python that’s easier to reason about and extend, this is a pattern worth understanding. 👉 Watch here: https://lnkd.in/eg22yEHR. #python #softwaredesign #designpatterns #statemachine #cleancode
To view or add a comment, sign in
-
-
📊 Comparing Two Outlier Removal Approaches in Python When cleaning datasets, how you remove outliers matters more than you think. I recently compared two common strategies: 1️⃣ Column-wise removal – Drop outliers sequentially, one column at a time. 2️⃣ Dataset-level removal – Flag all outliers across the entire dataset first, then remove them together. 🔍 What I found: The column-wise approach changes the IQR bounds after each removal, causing many non‑outlier rows to be wrongly filtered out (545 → 365 rows). The dataset-level approach respects original distributions, removes only true outliers (545 → 463 rows), and avoids over‑cleaning. ✅ Takeaway: Always identify outliers globally before removing them – your data will thank you. 📁 Used Python, pandas, IQR method, and a housing dataset. 🔗 Full code & notebook: https://lnkd.in/gheGYYEz #DataScience #Python #OutlierDetection #DataCleaning #Pandas #MachineLearning
To view or add a comment, sign in
-
Most implementations of the State pattern in Python look very “clean”. Lots of small classes. A base interface. One class per state. But if you’ve ever worked with one in a real project, you know the downside: transitions are scattered, behaviour is hard to see in one place, and adding new states often means touching multiple files. In today’s video, I rebuild the State pattern in a very different way. Instead of relying on inheritance, I make the state machine explicit as data and use decorators to define transitions. The result is a small, reusable engine where the entire flow becomes visible at a glance. If you’re interested in writing Python that’s easier to reason about and extend, this is a pattern worth understanding. 👉 Watch here: https://lnkd.in/e9Y3xGNF. #python #softwaredesign #designpatterns #statemachine #cleancode
To view or add a comment, sign in
-
-
🅸🅽🅿🆄🆃 & 🅾🆄🆃🅿🆄🆃 🅵🆄🅽🅲🆄🆃🅸🅾🅽🆂 📦 Definition: In Python, Input is how we get data from the user into our program, and Output is how the program displays information back to the user. 🏠 Real-World Example: Think of a Vending Machine. Input: You press the buttons to tell the machine you want a "B3" (snack code). Output: The machine displays "Price: $1.50" on the screen and then drops your chips! 🍟 Without that type interaction, the machine is just a silent box of snacks. Here is how we do it in Python: 👉 input(): This function pauses the program and waits for you to type something. Python always treats input as a string by default, so if we want numbers, we will need to wrap it in an int() or float(). 👉 print(): It takes whatever is inside the parentheses and splashes it onto the screen for the world to see. #python #inputoutput #codingtips #pythonsimplified #datananalytics #learnpython
To view or add a comment, sign in
-
-
Finally moved Python & AI project from local to live! 🎈 I’ve been experimenting with Python lately and finished building a simple Personal Assistant for my morning routines and productivity. It was fun to step outside .NET and try out some new tools: ⚡ Groq : Really impressed with how fast the responses are. 🐍 Python: Getting more comfortable with the syntax every day. 🖥️ Streamlit: Made it super easy to put a clean UI on top. It’s work in progress, but you can check out V1 here: https://lnkd.in/gwyuaGZt #Python #Streamlit #PersonalProject #BuildingInPublic #WomenInCode
To view or add a comment, sign in
-
-
Python Series — Day 3 🧠 Let’s level it up a bit 👇 What will be the output of this code? def modify_list(lst): lst.append(4) a = [1, 2, 3] modify_list(a) print(a) Options: A. [1, 2, 3] B. [1, 2, 3, 4] C. Error D. None Think carefully 👀 (Hint: It’s not about functions… it’s about how Python handles data) Drop your answer 👇 Answer tomorrow 🚀 #Python #CodingChallenge #LearningInPublic #DataEngineering #Tech
To view or add a comment, sign in
-
-
Spent Q1 running around 22,000 DocsBot conversations through a Python analysis pipeline to stop guessing which WPForms docs needed work. Output: 278 existing pages that need fixes, 100+ recurring feature requests, 15 topics users keep asking about that don't have a doc yet. The surprise wasn't the numbers. It was the ranking. The three pages I would have prioritized from gut feel weren't even close to the top. Meanwhile, a couple of pages I assumed were fine had dozens of confused conversations attached to them. Nothing fancy on the pipeline side. Python, an LLM, and clustering on the conversation data. Changed what I'm prioritizing for Q2.
To view or add a comment, sign in
-
An exercise to help build the right mental model for Python data. - Solution: https://lnkd.in/eEi7JZ7t - Explanation: https://lnkd.in/ebPVvnhx - More exercises: https://lnkd.in/eQSdJdaW The “Solution” link visualizes execution and reveals what’s actually happening using 𝗺𝗲𝗺𝗼𝗿𝘆_𝗴𝗿𝗮𝗽𝗵: https://lnkd.in/e3sUM7wG
To view or add a comment, sign in
-
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