✅ *Python Programming Basics* 🐍💻 *📌 Step 1: Install Python & VS Code* • Download Python 3.11+ from python.org • During install, check ✅ *Add Python to PATH* • Install *VS Code* • In VS Code, install the *Python* extension To check: Open terminal → Type: `python --version` You should see something like: `Python 3.x.x` *📌 Step 2: Your First Python Program* Create a file: `hello.py` Paste this code: ``` print("Hello, Python") ``` Run it in terminal: `python hello.py` 🧠 Python runs code top to bottom 🖨️ `print()` displays output on the screen *📌 Step 3: Variables* Variables store values. ``` age = 25 name = "Deepak" height = 5.11 print(age, name, height) ``` ✔️ No need to declare types — Python figures it out ✔️ Use lowercase names with underscores *📌 Step 4: Data Types* • `int` → Whole numbers (e.g., 10) • `float` → Decimals (e.g., 3.14) • `str` → Text (e.g., "hello") • `bool` → True / False To check type: ``` x = 10 print(type(x)) ``` *📌 Step 5: Input & Output* Take input from user: ```python name = input("Enter your name: ") print("Hello", name) ``` Convert string input to number: ``` age = int(input("Enter age: ")) print("Next year you'll be", age + 1) ``` *📌 Step 6: Arithmetic Operators* ``` a = 10 b = 3 print(a + b) # Add print(a - b) # Subtract print(a * b) # Multiply print(a / b) # Divide print(a // b) # Floor division print(a % b) # Remainder ``` *📌 Step 7: String Operations* ``` first = "Data" second = "Analyst" print(first + " " + second) # Concatenate print("Hi " * 3) # Repeat print(len(first)) # Length ``` *📌 Step 8: Practice Programs* 1️⃣ Simple Calculator → Input 2 numbers, show sum, difference, product, division 2️⃣ Temperature Converter → Input Celsius, convert to Fahrenheit `F = (C * 9/5) + 32` 3️⃣ Age After 5 Years → Input current age, print age after 5 years Here is the detailed code for each project: 📌 *Project 1. Simple Calculator* ``` num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) print("Addition:", num1 + num2) print("Subtraction:", num1 - num2) print("Multiplication:", num1 * num2) if num2 != 0: print("Division:", num1 / num2) else: print("Division not possible") ``` 📌 *Project 2. Temperature Converter (Celsius to Fahrenheit)* ``` celsius = float(input("Enter temperature in Celsius: ")) fahrenheit = (celsius * 9 / 5) + 32 print("Temperature in Fahrenheit:", fahrenheit) ``` 📌 *Project 3. Age After 5 Years* ``` age = int(input("Enter your age: ")) future_age = age + 5 print("Your age after 5 years:", future_age) ``` 🎁 *Bonus Practice – Area of a Rectangle* ``` length = float(input("Enter length: ")) width = float(input("Enter width: ")) area = length * width print("Area of rectangle:", area) ```
Python Programming Basics: Install Python & VS Code, Variables, Data Types & More
More Relevant Posts
-
Today, let's start with the first topic in Python Programming Roadmap: Python Programming Basics Step 1: Install Python & VS Code • Download Python 3.11+ from python.org • During install, check Add Python to PATH • Install VS Code • In VS Code, install the Python extension To check: Open terminal → Type: `python-version` You should see something like: `Python 3.x.x` Step 2: Your First Python Program Create a file: `hello.py` Paste this code: print("Hello, Python") Run it in terminal: `python hello.py` Python runs code top to bottom print()` displays output on the screen Step 3: Variables Variables store values. age = 25 name = "Deepak" height = 5.11 print(age, name, height) -No need to declare types — Python figures it out -Use lowercase names with underscores Step 4: Data Types • `int` → Whole numbers (e.g., 10) • `float` → Decimals (e.g., 3.14) • `str` → Text (e.g., "hello") • `bool` → True / False To check type: x = 10 print(type(x)) Step 5: Input & Output Take input from user: ```python name = input("Enter your name: ") print("Hello", name) Convert string input to number: age = int(input("Enter age: ")) print("Next year you'll be", age + 1) Step 6: Arithmetic Operators a = 10 b = 3 print(a + b) print(a - b) print(a * b) print(a / b) print(a // b) print(a % b) Step 7: String Operations ``` first = "Data" second = "Analyst" print(first + " " + second) # Concatenate print("Hi " * 3) # Repeat print(len(first)) # Length Step 8: Practice Programs * Simple Calculator → Input 2 numbers, show sum, difference, product, division *Temperature Converter → Input Celsius, convert to Fahrenheit `F = (C * 9/5) + 32` *Age After 5 Years → Input current age, print age after 5 years Here is the detailed code for each project: Project 1. Simple Calculator ``` num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) print("Addition:", num1 + num2) print("Subtraction:", num1 - num2) print("Multiplication:", num1 * num2) if num2 != 0: print("Division:", num1 / num2) else: print("Division not possible") Project 2. Temperature Converter (Celsius to Fahrenheit) celsius = float(input("Enter temperature in Celsius: ")) fahrenheit = (celsius * 9 / 5) + 32 print("Temperature in Fahrenheit:", fahrenheit) Project 3. Age After 5 Years age = int(input("Enter your age: ")) future_age = age + 5 print("Your age after 5 years:", future_age) Bonus Practice – Area of a Rectangle length = float(input("Enter length: ")) width = float(input("Enter width: ")) area = length * width print("Area of rectangle:", area) Useful Tips • Run each program • Change input values • Break it on purpose and fix it Daily Rule: • Code at least 60 mins • Type every line manually • Don’t copy-paste — build muscle memory Python Programming Roadmap: https://lnkd.in/eWvZcyeY
To view or add a comment, sign in
-
-
🧠 Python Concept You MUST Know: __slots__ (Memory Optimization in Classes) Most Python developers never use __slots__, but those who do understand Python deeply. Let’s explain it simply 👇 🧒 Simple Explanation Imagine each student gets a school bag 🎒. Normally, the bag is big and flexible — you can put anything inside. But sometimes, you want a small, fixed bag that holds only specific items. That’s what __slots__ does. 🔹 Normal Class (Flexible but Heavy) class Person: def __init__(self, name, age): self.name = name self.age = age Each object: ✔️ Has a dictionary (__dict__) ✔️ Uses more memory ✔️ Can add new attributes anytime 🔹 Class with __slots__ (Lightweight) class Person: __slots__ = ("name", "age") def __init__(self, name, age): self.name = name self.age = age Now: ✔ No __dict__ ✔ Less memory per object ✔ Faster attribute access ✔ No extra attributes allowed 🤯 What Happens If You Try This? p = Person("Sam", 20) p.height = 170 ❌ Error: AttributeError: 'Person' object has no attribute 'height' Because __slots__ locks the structure. 🚀 When Should You Use __slots__? Use it when: ✔ You create many objects ✔ Memory matters ✔ Object structure is fixed ✔ Performance is important Used heavily in: 🖥️ Game engines 🖥️ Data models 🖥️ High-performance systems ⚠️ When NOT to Use It Avoid __slots__ when: ✖ You need flexibility ✖ You dynamically add attributes ✖ You’re still prototyping 🎯 Interview Gold Line “__slots__ removes the instance dictionary to reduce memory usage.” Short. Powerful. Correct. 🧠 One-Line Rule Use __slots__ for many objects with fixed attributes. ✨ Final Thought __slots__ is not about writing less code — it’s about writing smarter Python. 📌 Save this post — this is an advanced Python skill. #Python #LearnPython #PythonDeveloper #PythonTips #__slots__ #MemoryOptimization #PythonInternals #CleanCode #Performance #SoftwareEngineering #TechLearning #DeveloperLife
To view or add a comment, sign in
-
-
Day 57 of my Python Journey 👨🏽💻 🔥 Modular Programming & Data Persistence! 🔥 I kicked off today with the intention of building more advanced projects using the concept of python modules and i challenged myself by building a functional Phone Book✨. Building this wasn't easy 😅 because I tried to replicate a simple phonebook project i built in the past using only python dictionaries and i faced a persistent problem anytime I ran the code 😤💔, Any new contact i input kept disappearing after i exit PyCharm. So I did a little research and found out about python's built-in function called JSON which turned out to be a life saver 😅😃 How it was written 👇🏽 📁 Started by creating the module file that contains logic (PhoneBook.py) which handles the backend operations—creating, reading, and clearing data. In this file: ~ I imported "json" which is a built-in python library used to save data to a file and load it back later🔥, FILE_NAME = "contacts.json" defines the file name as a constant. ~ Then I defined a function named loadContacts() that attempts to open the JSON file in read mode ("r"). if u watch the video you would find a function written beneath it called json.load(file) that converts the inputted user text inside the file back into a usable dictionary. ~ saveContacts(contacts) was also defined and it is the function that opens the file in write mode ("w"). This overwrites the existing file with new data using json.dump() ~ The addContact(contacts, name, phone) function adds a new key-value pair (Name -> Number) to the dictionary. ~ saveContacts(contacts) immediately saves the updated dictionary to the file so data isn't lost and clearContacts() calls back saveContacts({}) passing an empty dictionary in it {} which effectively overwrites the file thereby deleting all contacts ✅ 📁 The second file (main.py) which is the interface and easiest to write 😅 simply handles the user experience (input/output) and menu loop ✨.main.py generally takes the input and calls the recquired functions for updating, deleting and saving of data. I'm glad i was able to successfully make the data persistent. Even if the program closes, the contacts remain saved ✨🔥😚 It feels so rewarding to build with already learned concepts and see the projects come alive. Seeing how modules interact with one another and gave me a much clearer understanding of how real-world software is structured ✨.. Check out a snippet of the code below! 👇🏽😊 #BuildingInPublic #Python #Coding #EngineeringStudent #SoftwareDevelopment #LearningProgress #Programming #Modules #JSON #100DaysOfCode
To view or add a comment, sign in
-
*Complete Python Roadmap* 👇 1. Introduction to Python - Definition - Purpose - Python Installation - Interpreter vs Compiler 2. Basic Python Syntax - Print Statement - Variables and Data Types - Input and Output - Operators 3. Control Flow - Conditional Statements (if, elif, else) - Loops (for, while) - Break and Continue Statements 4. Data Structures - Lists - Tuples - Sets - Dictionaries 5. Functions - Function Definition - Parameters and Return Values - Lambda Functions 6. File Handling - Reading from and Writing to Files - Handling Exceptions 7. Modules and Packages - Importing Modules - Creating Packages 8. Object-Oriented Programming (OOP) - Classes and Objects - Inheritance - Polymorphism - Encapsulation - Abstraction 9. Error Handling - Try, Except Blocks - Custom Exceptions 10. Advanced Data Structures - List Comprehensions - Generators - Collections Module 11. Decorators and Generators - Function Decorators - Generator Functions 12. Working with APIs - Making HTTP Requests - JSON Handling 13. Database Interaction with Python - Connecting to Databases - CRUD Operations 14. Web Development with Flask/Django - Flask/Django Setup - Routing and Templates 15. Asynchronous Programming - Async/Await - Asyncio Library 16. Testing in Python - Unit Testing - Testing Frameworks (e.g., pytest) 17. Pythonic Code - PEP 8 Style Guide - Code Readability 18. Version Control (Git) - Basic Commands - Collaborative Development 19. Data Science Libraries - NumPy - Pandas - Matplotlib 20. Machine Learning Basics - Scikit-Learn - Model Training and Evaluation 21. Web Scraping - BeautifulSoup - Scrapy 22. RESTful API Development - Flask/Django Rest Framework 23. CI/CD Basics - Continuous Integration - Continuous Deployment 24. Deployment - Deploying Python Applications - Hosting Platforms (e.g., Heroku) 25. Security Best Practices - Input Validation - Handling Sensitive Data 26. Code Documentation - Docstrings - Generating Documentation 27. Community and Collaboration - Open Source Contributions - Forums and Conferences *Resources to Learn Python:* 1. Free Course - https://lnkd.in/dttpg3bF 2. Projects - https://lnkd.in/dBYyDqVn - t.me/pythonspecialist/90 3. Books & Notes - https://t.me/dsabooks/99 - https://t.me/dsabooks/101 4. Python Interview Preparation - https://lnkd.in/d7e3pRi2 - https://lnkd.in/dTQG9ErE Free Python resources: https://lnkd.in/deR5HPNf Like this post if you want more content like this 😄❤️ ENJOY LEARNING 👍👍
To view or add a comment, sign in
-
-
One of the reasons Python dominates finance, risk, data, and automation roles is how much you can do with so little code. The "magic" of Python comes from its readability and the way it handles complex data structures in a single line. Below are 10 Python-specific features and functions that makes Python better than any other Programming Language - features that consistently impress me. 1. List Comprehensions While other languages uses complex looping structure to create lists, Python does it in one readable line. Create a list of squares for even numbers squares = [x**2 for x in range(10) if x % 2 == 0] 2. The zip() Function Python’s zip() allows you to iterate over multiple lists simultaneously without using index counters—a common source of bugs in C++ or Java. names = ["Babubhai", "Goud"] scores = [85, 92] for name, score in zip(names, scores): print(f"{name}: {score}") 3. F-Strings (Formatted Strings) Introduced in Python 3.6, f-strings are arguably the cleanest string interpolation method in any language, allowing expressions directly inside the braces. print(f"The result is {2 + 2}, and the name is {name.upper()}.") 4. Unpacking and Swapping You can swap two variables without a "temp" variable, or unpack a list into variables using the * operator. a, b = b, a first, *middle, last = [1, 2, 3, 4, 5] 5. enumerate() Instead of managing a manual counter (i = 0; i += 1), enumerate() gives you the index and the value at the same time. for index, value in enumerate(["a", "b", "c"]): print(index, value) 6. The with Statement (Context Managers) Python handles resource management (like closing files or database connections) automatically, preventing memory leaks better than manual try-finally blocks. with open("data.txt") as f: data = f.read() 7. Dictionaries with .get() and setdefault() Python dictionaries are incredibly robust. The .get() method prevents your code from crashing if a key is missing by providing a default value. count = my_dict.get("unknown_key", 0) 8. collections.Counter Counting occurrences in a list takes dozens of lines in other languages; in Python, it's a single class import from the Standard Library. from collections import Counter counts = Counter("abracadabra") # {'a': 5, 'b': 2, 'r': 2, 'c': 1, 'd': 1} 9. Slicing with Steps Python’s [start:stop:step] syntax is the most intuitive way to manipulate arrays and strings, including reversing them. reversed_str = "Python"[::-1] # 'nohtyP' 10. itertools Module For handling permutations, combinations, or infinite cycles, Python’s itertools is significantly more efficient and readable than writing custom nested loops. import itertools pairs = list(itertools.combinations([1, 2, 3], 2)) # [(1, 2), (1, 3), (2, 3)]
To view or add a comment, sign in
-
DAY 5 of Python Programming: Working with Text (Strings) in Python 🐍📝 (Text is everywhere in programming) 1/ So far, we’ve printed text and done math. Today, we learn how Python handles text properly. In Python, text is called a string. 2/ A string is anything inside quotes: code Python name = "Kehinde" country = "Nigeria" If it’s inside " " or ' ', Python treats it as text. 3/ You can combine strings together. This is called concatenation. Example: code Python first_name = "Kehinde" last_name = "Fasola" print(first_name + " " + last_name) That space " " is important 👀 4/ Let’s fix a common beginner problem. This will cause an error ❌ code Python age = 25 print("I am " + age) Why? Because Python can’t mix text and numbers directly. 5/ Correct way #1: Separate with commas ✅ code Python age = 25 print("I am", age, "years old") Python handles the conversion for you. 6/ Correct way #2 (BEST way): f-strings 🔥 code Python name = "Kehinde" age = 25 print(f"My name is {name} and I am {age} years old") This is clean, modern, and powerful. 7/ Strings can also be: • Uppercase • Lowercase • Counted Examples: code Python text = "Python" print(text.upper()) print(text.lower()) print(len(text)) Python gives you tools for free. 8/ Today’s challenge Create variables for: ✔ Your name ✔ Your age ✔ Your country Print ONE sentence using an f-string like: code: My name is ___, I am ___ years old and I live in ___ Reply DONE if it worked 9/ Tomorrow (Day 6): • Getting input from users • Making programs interactive • Your code will start asking questions 😎 Follow & turn on notifications 🐍💻 You’re leveling up fast.
To view or add a comment, sign in
-
Dagster’s Best Practices in Structuring Python Projects for Data Engineering blog series: Part 1-2 : Python Packages: a Primer for Data People (part 1 , 2) https://lnkd.in/esV-ft52 https://lnkd.in/e_JUS6jG Part 3: Best Practices in Structuring Python Projects, covered 9 best practices and examples on structuring your projects. https://lnkd.in/eWn9TXz3 Part 4: From Python Projects to Dagster Pipelines: https://lnkd.in/ekrefxNV Part 5: Environment Variables in Python: https://lnkd.in/eNTFDPch Part 6: Type Hinting, or how type hints reduce errors: https://lnkd.in/eeRcYtH4 Part 7: Factory Patterns, or learning design patterns, which are reusable solutions to common problems in software design. https://lnkd.in/e8hUZW9j Part 8: Write-Audit-Publish in data pipelines a design pattern frequently used in ETL to ensure data quality and reliability. https://lnkd.in/emuwRURX Part 9: CI/CD and Data Pipeline Automation (with Git), learn to automate data pipelines and deployments with Git. https://lnkd.in/eD-nT45S Part 10: High-performance Python for Data Engineering, learn how to code data pipelines in Python for performance. https://lnkd.in/efcreZG3 Part 11: Breaking Packages in Python, in which we explore the sharp edges of Python’s system of imports, modules, and packages. https://lnkd.in/edYbdAsT
To view or add a comment, sign in
-
🧠 Data Structures in Python — Explained Simply Data structures are the backbone of programming. They define how data is stored, accessed, and modified. This visual focuses mainly on Lists, the most commonly used data structure in Python. 📌 Collections in Python Python provides several built-in collection types such as: Lists Tuples Sets Dictionaries Arrays Among these, Lists are the most popular because they are flexible and easy to use. 📋 Lists Lists are ordered collections of elements They are mutable (you can change values) Created using: myList = [] A list can store different data types (int, string, list, etc.) 🔁 Loops & Iteration Lists are commonly accessed using loops A common idiom is: for elem in myList Loops help process elements one by one 🔢 Indexes Every element in a list has an index Indexing starts from 0 Forward indexing: 0 to length-1 Backward indexing: -1 to -length Access syntax: myList[index] ✏️ Assignment & Modification List elements can be modified using indexes Example: myList[ind] = x This is possible because lists are mutable ⚙️ List Methods Lists come with built-in methods like: .append() → add element .sort() → sort elements These methods make lists powerful and efficient. 📌 Key Takeaway If you understand lists, indexes, and loops, you already understand 80% of Python data structures. Save this post 🔖 — it’s a must-know foundation for every Python learner. #Python #DataStructures #ProgrammingBasics #PythonLearning #Coding #DSA #ComputerScience #DeveloperJourney #TechSkills #LearnToCode
To view or add a comment, sign in
-
-
Now, let's move to the next topic in Python Programming Roadmap: *✅ Python Functions Part-1* *What a function is* - A block of reusable code - Runs only when you call it - Solves one specific task *Why you need functions* - Avoid repetition - Improve readability - Easier debugging *Basic function* def greet(): print("Hello") greet() *Function with parameters* def greet(name): print("Hello", name) greet("Deepak") - *Key idea* - Parameters receive data - Arguments send data *Function with return value* def add(a, b): return a + b result = add(10, 20) print(result) *Important rule* - return gives output back - print only shows output *Wrong way beginners use* def add(a, b): print(a + b) This cannot be reused in calculations. *Correct way* def add(a, b): return a + b *Multiple return paths* def check_pass(marks): if marks >= 40: return "Pass" else: return "Fail" *Default parameters* def power(base, exp=2): return base ** exp print(power(5)) print(power(5, 3)) *Function calling function* def square(n): return n * n def cube(n): return square(n) * n print(cube(3)) *Common mistakes* - Forgetting return - Using print instead of return - Wrong indentation - Calling function before definition *Mini practice for you* - Practice tasks for you. - Function to calculate square of a number - Function to check prime number - Function to find maximum of two numbers - Function to calculate simple interest - Function to count vowels in a string *Mini practice task for you* 👇 - *Function to calculate square of a number* def square(n): return n * n print(square(5)) # 25 - *Function to check prime number* def is_prime(n): if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True print(is_prime(7)) # True print(is_prime(10)) # False - *Function to find maximum of two numbers* def find_max(a, b): if a > b: return a return b print(find_max(10, 20)) # 20 - *Function to calculate simple interest* def simple_interest(principal, rate, time): return (principal * rate * time) / 100 print(simple_interest(1000, 5, 2)) # 100.0 - *Function to count vowels in a string* def count_vowels(text): vowels = "aeiouAEIOU" count = 0 for char in text: if char in vowels: count += 1 return count print(count_vowels("Python Programming")) # 4 - *Rule to remember* - One function, one job - Name functions clearly
To view or add a comment, sign in
More from this author
-
Study demonstrates integration of 1,024 silicon quantum dots with on-chip electronics all operating at low temperatures
Bincy Mathew 1y -
100GbE SOSA Development Kit with RFSoC or 64 GSps Direct RF I/O - What They Are and How They Work?
Bincy Mathew 1y -
Embedded computing systems with cyber security for mission processing - What They Are and How They Work?
Bincy Mathew 1y
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
💡*Useful Tips* • Run each program • Change input values • Break it on purpose and fix it 🧠 *Daily Rule:* • Code at least 60 mins • Type every line manually • Don’t copy-paste — build muscle memory