💻 Everyone learns Python data types. But few ask how much memory they actually use. As part of my AI diploma, I looked into it — and the answer isn’t as simple as you’d expect. Here’s what I found 👇 🔍 Short answer: It depends. Unlike languages like C or Java, Python doesn’t fix memory sizes. It uses dynamic typing and flexible memory management. 📊 How common types behave: int → No fixed size Can grow as large as memory allows (no traditional overflow) float → Typically 64-bit Similar to C’s double bool → Subclass of int Stored as an object (not just 1 byte) str → Variable size Uses flexible internal encoding depending on characters list / tuple → Store references Not the actual values directly 💡 Why does Python work this way? Flexibility. No need to declare types No need to manage memory manually Easier and safer for developers ⚠️ The trade-off More flexibility = more memory usage A Python int can take around 28 bytes while a C int takes only 4 bytes Same value — very different cost. My biggest takeaway? Python hides memory complexity — but understanding it makes you a better programmer. 💬 Did this surprise you? Thank you Eng. Jana Hatem for pushing us to look deeper❤️ #Python #Programming #DataTypes #ComputerScience #LearningInPublic #TechExplained
Python Data Types Memory Usage Explained
More Relevant Posts
-
Python Learning Journey - Dictionaries Deep Dive Dictionaries are one of the most powerful and flexible data structures in Python. Today, I explored some important functions that every developer should know Core Dictionary Functions: len() - Returns number of key-value pairs clear() - Removes all elements get() - Access values safely without errors pop() - Removes specific key and returns its value popitem() - Removes last inserted key-value pair keys() - Returns all keys items() - Returns key-value pairs copy() - Creates a shallow copy setdefault() - Returns value of key (adds if not present) update() - Updates dictionary with new key-value pairs Advanced Concept: Dictionary Comprehension - A concise way to create dictionaries in a single line Example: {x: x*x for x in range(5)} Mastering dictionaries helps in writing efficient and clean code, especially when working with real-world data. #Globalquesttechnologies #GR Narendra Reddy #Python #Coding Journey #100DaysOfCode #Programming #Software Development #PythonBasics #Learning
To view or add a comment, sign in
-
-
Understanding Regular Expressions in Python Regular Expressions (RegEx) are powerful tools used for searching, matching, and manipulating text. In Python, they are handled using the built-in re module. Why use RegEx? • Validate inputs (emails, phone numbers, passwords) • Search for specific patterns in text • Extract useful data from large datasets • Replace or clean text efficiently Key Functions in Python RegEx: • re.search() → Finds first match • re.findall() → Finds all matches • re.sub() → Replaces text • re.match() → Matches from beginning Final Thought: Mastering Regular Expressions can significantly boost your data processing and text handling skills as a developer. Thanks for : Sultan AL-Yahyai CodeAcademy_om Kulsoom Shoukat Ali #Python #Programming #DataAnalysis #Coding #RegularExpressions #TechSkills #Learning #Developers
To view or add a comment, sign in
-
-
🚀 Day 9 of Python Learning: Dictionary in Python Today I learned about Dictionaries — one of the most powerful data structures in Python for storing data in key-value pairs. 🔹 What is a Dictionary? A dictionary stores data in pairs: key and value. It is useful when you want to store structured information like user details, product data, etc. 🔸 Creating a Dictionary student = { "name": "Rohit", "age": 22, "city": "Meerut" } 🔸 Accessing Values print(student["name"]) print(student["age"]) 🔸 Adding New Data student["course"] = "Python" 🔸 Updating Data student["age"] = 23 🔸 Removing Data student.pop("city") 💡 Key Learning: Dictionaries are mutable and allow fast access to data using keys. 🧪 Practice Task: ✔ Create a dictionary with your name, age, and city ✔ Add one new key-value pair ✔ Update one value ✔ Print all keys and values using a loop 🎯 Interview Question: What is the difference between list and dictionary in Python? Answer: A list stores ordered values using indexes, while a dictionary stores data using key-value pairs. 📌 Day 9 completed — growing every single day! #Python #Learning #CodingJourney #Day9 #Programming #SDET #100DaysOfCode Masai #masaiverse #dailyleaning
To view or add a comment, sign in
-
Fundamentals… Many of us are avid users of the Python Pandas library. The read_csv function is the basic step in reading data. After data is read, the most basic model to create is a simple linear regression model. While we (including myself) deal with the abstracted form of these functions, in a learning curve, it is imperative we understand what happens at the basic level. And when dealing with programming at the basic level, then it is not far fetched to bring the C language into discussion. Learning C is fun, it tires you out sometimes, specially when you’ve learnt C++, Python and Java beforehand, C is still important. While writing this subroutine, I was able to think from a fundamental perspective as to how, FILE input is read, how to escape string delimiters, how to read integer input, perform operations on it to build a function, we use so widely. Read the code, and you’ll understand, how memory allocation is being done depending on the file, how operations are formed and stored to be reused, what is scope and what would happen in variables are accessed outside of scope. Learning the fundamentals not only helps you in becoming better engineers but also lets you think in a manner where you can solve problems at the basic level without a lot of overhead. P.S( The code might replicate the initial functionality, but it still doesn’t work a optimally, but it does provide a fundamental layout, suggestions and improvements are always welcome). Link: https://lnkd.in/ggPaeRx2 #opensource #C #programming #fundamentals #learninpublic
To view or add a comment, sign in
-
-
Python Learning Journey – Dictionaries Deep Dive Dictionaries are one of the most powerful and flexible data structures in Python. Today, I explored some important functions that every developer should know 👇 📌 Core Dictionary Functions: ✔️ len() – Returns number of key-value pairs ✔️ clear() – Removes all elements ✔️ get() – Access values safely without errors ✔️ pop() – Removes specific key and returns its value ✔️ popitem() – Removes last inserted key-value pair ✔️ keys() – Returns all keys ✔️ items() – Returns key-value pairs ✔️ copy() – Creates a shallow copy ✔️ setdefault() – Returns value of key (adds if not present) ✔️ update() – Updates dictionary with new key-value pairs 💡 Advanced Concept: ✨ Dictionary Comprehension – A concise way to create dictionaries in a single line Example: {x: x*x for x in range(5)} 🎯 Mastering dictionaries helps in writing efficient and clean code, especially when working with real-world data. #Globalquesttechnologies #GR Narendra Reddy #Python #CodingJourney #100DaysOfCode #Programming #SoftwareDevelopment #PythonBasics #Learning
To view or add a comment, sign in
-
-
💻 Python Task – Contact Management I recently worked on a simple Python task as part of my learning journey 😊 🔹 What I did: 🟢 Created a 2D list to store contact details (Name, Phone, Email) 🔵 Added new contacts using input() 🟡 Removed the last contact from the list 🟠 Took user inputs and updated the list 🟣 Sorted the contacts in ascending order 🔴 Displayed all contacts in a clean and readable format ⚪ Handled multiple entries using loops 🔹 What I learned: 🟢 Working with lists and nested lists 🔵 Taking user input in Python 🟡 Performing basic operations (add, remove, sort) 🟠 Using loops to manage repeated actions 🟣 Improving logical thinking and problem-solving 🔹 What I understood: This task helped me see how Python can be used to handle real-world data step by step. Even with simple logic, we can build useful mini applications 👍 🚀 Excited to keep learning and build more useful programs step by step! #Python #DataAnalyst #CodingJourney #LearningByDoing
To view or add a comment, sign in
-
-
DATA ANALYSIS USING PYTHON by (logicstack.org) If you’ve ever looked at raw data and thought, “Yeh samajh kaise aata hai?” this course is for you. In Data Analysis Using Python, I’m going to take you step-by-step from zero confusion to actually understanding how data works in the real world. We’re not just learning theory… we’ll work with real datasets, clean messy data, and turn numbers into meaningful insights. You’ll learn how to use Python like a proper analyst from basic data handling to powerful libraries that companies actually use. No boring lectures, no unnecessary complexity… just clear concepts, practical examples, and skills you can apply. Whether you’re a student, beginner, or someone switching into tech, this course will give you a strong foundation in data analysis. #dataanalysis #python #freecourse #training #logicstack
To view or add a comment, sign in
-
-
🚀 Day 13 of Python Learning: Exception Handling in Python Today I learned how to handle errors in Python using exception handling. This helps programs run smoothly even when unexpected issues occur. 🔹 What is Exception Handling? Exception handling is used to catch errors and prevent the program from crashing. 🔸 Basic Example try: num = 10 / 0 except: print("Error occurred") 🔸 Handling Specific Error try: number = int("abc") except ValueError: print("Invalid input") 🔸 Using Finally Block try: print("Start") except: print("Error") finally: print("This always runs") 🔸 Using Else Block try: print(10 / 2) except: print("Error") else: print("No error found") 💡 Key Learning: Using try-except makes programs more reliable and user-friendly. 🧪 Practice Task: ✔ Handle divide by zero error ✔ Handle invalid number input ✔ Use finally block in one program ✔ Create a safe calculator using try-except 🎯 Interview Question: What is the purpose of finally block in Python? Answer: The finally block always executes whether an error occurs or not. It is commonly used for cleanup tasks like closing files or database connections. 📌 Day 13 completed — learning how professionals handle errors! #Python #Learning #CodingJourney #Day13 #Programming #SDET #100DaysOfCode Masai #masaiverse #dailylearning
To view or add a comment, sign in
-
Ever been confused why sometimes comparing two things in Python gives a weird result, or why identical looking lists are suddenly "not equal"? I was stuck on this for hours yaar when learning about object identity versus value. It's a common beginner pitfall that can lead to unexpected bugs. Understanding `is` versus `==` is super important for writing correct Python code. Here's a quick breakdown: - `==` (Equality operator): This checks if the *values* of two objects are the same. It compares what's inside the objects. - `is` (Identity operator): This checks if two variables refer to the *exact same object* in memory. Think of it as checking if they point to the same storage location. - For immutable types like integers and strings, Python often optimizes by using the same object for identical values within a certain range. For example, `a = 500; b = 500; print(a is b)` might be `False` because 500 is outside the optimized range (-5 to 256). - However, for `a = 10; b = 10; print(a is b)`, it will usually be `True` because `10` is a small integer, often cached. It's a memory optimization. - When you create two separate lists, even if they have the same elements, they are distinct objects in memory. `list1 = [1, 2]; list2 = [1, 2]; print(list1 == list2)` will be `True`, but `print(list1 is list2)` will be `False`. Knowing this difference helps debug a lot of subtle issues, especially when working with mutable objects like lists and dictionaries. What other Python quirks have you found tricky? #Python #PythonTips #BeginnerPython #CodingIndia #Freshers
To view or add a comment, sign in
-
🚀 Day 12 of Python Learning: File Handling in Python Today I learned how Python can create, read, write, and update files. File handling is very useful for storing data permanently. 🔹 What is File Handling? File handling allows us to work with text files and save information outside the program. 🔸 Opening a File file = open("data.txt", "r") 🔸 Reading a File print(file.read()) 🔸 Writing to a File file = open("data.txt", "w") file.write("Hello Python") 🔸 Appending Data file = open("data.txt", "a") file.write("\nNew Line Added") 🔸 Best Practice: Close File file.close() 🔸 Better Way Using with Statement with open("data.txt", "r") as file: print(file.read()) 💡 Key Learning: Using "with open()" is safer because Python automatically closes the file after use. 🧪 Practice Task: ✔ Create a file and write your name ✔ Append your city name ✔ Read the file content ✔ Count total lines in the file 🎯 Interview Question: What is the difference between "w" and "a" mode in Python file handling? Answer: "w" mode overwrites existing content, while "a" mode adds new content at the end of the file. 📌 Day 12 completed — learning practical Python skills daily! #Python #Learning #CodingJourney #Day12 #Programming #SDET #100DaysOfCode Masai #masaiverse #Dailylearning
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