Day 1️⃣ of my Python Journey 100 Days, 100 Projects Day 1️⃣ Topic: Working with Variables, Input, String Formatting (f-strings), and the datetime module. Before I started the Day 1 task, the course included a Python crash course video to help refresh previously learned concepts. This section served as a quick revision of the fundamentals such as variables, loops, conditionals, and the basic structure of Python programs. Going through this video helped reinforce my understanding and prepared me for the projects to be made. During this revision, I also learned about functions, which was something I didn’t previously have much prior knowledge about💔. Functions allow you to create your own reusable commands so that instead of repeating the same block of code multiple times, you can organize it into a function and call it whenever needed. I also learned that variables inside functions are known as parameters, which allow the function to accept and work with different inputs. After learning about functions, I built a small mini-project (first picture in the collage): a number guessing game. In this project, I worked with Python’s random library, specifically the randint() function, which generates a random number within a given range. The program randomly selects a number between 1 and 10, and the user is given three attempts to guess the correct number. This project helped me understand how libraries can extend Python’s functionality and how randomness can be introduced into a program. It also allowed me to combine conditional statements, loops, and user input to create a simple interactive program. I then moved on to the Day 1 main project (second picture in the collage), which was to create a simple program that welcomes a user. The program was created in the thonny IDE, because of network issues using the Google Collab website. The program asks the user for their name and favorite color using the input() function. I used f-strings to dynamically format the output so the response would be more readable and personalized. I also used title case formatting to ensure that the user’s name appears properly formatted, there are other case formatting styles like upper and lower, but since it is a sentence, I added the title case for more grammatical accuracy. To add more functionality, I imported the datetime module, which allowed the program to display the exact date and time when the user entered their information. This showed how Python programs can interact with system data to provide more context. Even though today’s project was simple, it helped me combine several concepts: functions, parameters, libraries, randomness using randint(), user input, string formatting, and modules. Looking forward to learning more and building bigger projects as the challenge continues. #Python #DataScience #100Projects #100Days0fCode #TechJourney #StudentGrowth
Python Journey Day 1: Variables, Functions, and Modules
More Relevant Posts
-
🧙♂️ Magic Methods in Python (Dunder Methods) Python is known for its powerful and flexible object-oriented features. One of the most interesting concepts in Python is Magic Methods, also called Dunder Methods (Double Underscore Methods). Magic methods allow developers to define how objects behave with built-in operations such as addition, printing, comparison, and more. These methods always start and end with double underscores (__). Example: __init__ __str__ __add__ __len__ They are automatically called by Python when certain operations are performed. --- 🔹 Why Magic Methods are Important? Magic methods help to: ✔ Customize the behavior of objects ✔ Make classes behave like built-in types ✔ Improve code readability ✔ Implement operator overloading They allow developers to write clean, powerful, and Pythonic code. --- 🔹 Commonly Used Magic Methods 1️⃣ __init__ – Constructor This method is automatically called when an object is created. class Student: def __init__(self, name): self.name = name s = Student("Vamshi") --- 2️⃣ __str__ – String Representation Defines what should be displayed when we print the object. class Student: def __init__(self, name): self.name = name def __str__(self): return f"Student name is {self.name}" s = Student("Vamshi") print(s) --- 3️⃣ __len__ – Length of Object Allows objects to work with the len() function. class Team: def __init__(self, members): self.members = members def __len__(self): return len(self.members) t = Team(["A", "B", "C"]) print(len(t)) 4️⃣ __add__ – Operator Overloading Defines how the + operator works for objects. class Number: def __init__(self, value): self.value = value def __add__(self, other): return self.value + other.value n1 = Number(10) n2 = Number(20) print(n1 + n2) 🔹 Key Takeaway Magic methods make Python classes more powerful and flexible by allowing objects to interact naturally with Python's built-in operations. Understanding magic methods helps developers write cleaner and more advanced object-oriented programs. #Python #PythonProgramming #MagicMethods #DunderMethods #OOP #Coding #LearnPython #SoftwareDevelopment
To view or add a comment, sign in
-
-
🚀 Day 3 – Python Practice Progress( 6 of 50 questions solved) Problems I practiced today: ✔ Check if a number is even or odd ✔ Find the largest of three numbers ✔ Print numbers from 1 to N ✔ Find the sum of numbers from 1 to N ✔ Check if a number is prime ✔ Check if a string is a palindrome While solving these, I practiced using: • Conditional statements • Loops (while / for) • Input validation using try–except • String slicing (for palindrome checking) 💡 One interesting concept I explored today was Python slicing: s = "python" print(s[::-1]) This reverses the string because the step -1 makes Python traverse the sequence backwards. Small problems like these are helping me build stronger problem-solving skills in Python. Looking forward to practicing more tomorrow. #Python #DataScience #Programming 1 Check if a number is even or odd. try: num1=int(input("Enter a Number : ")) if num1%2==0: print("number is even") else: print("number is odd") except ValueError: print("invalid input. Please enter a number") 2. Find the largest of three numbers. try: num1=int(input("Enter first Number: ")) num2=int(input("Enter second Number: ")) num3=int(input("Enter third Number: ")) if num1>num2 and num2>num3: print("Larget Number is :", num1) elif num2>num3 and num2>num1: print("Largest Number is :", num2) else: print("Largest Number is :", num3) except ValueError: print("invalid Input. Please enter a number") 3 Print numbers from 1 to N try: num1=int(input("Enter a Number: ")) if num1>0: s=0 while s<=num1: print(s) s=s+1; else: p=0 while p>=num1: print(p) p=p-1; except ValueError: print("invalid input, please enter a number") 4 Find the sum of numbers from 1 to N. try: num=int(input("Enter a number : ")) if num>0: s=0 i=0 while i<=num: s=s+i; i=i+1; print(s) else: p=0 q=0 while q >=num: p=p+q; q=q-1; print(p) except ValueError: print("invalid input. Enter correct Number") Check if a number is prime. try: num=int(input("Enter a number : ")) if num>1: is_prime=True i=2 while i <num: if num%i==0: is_prime=False break i=i+1 if is_prime: print("Number is prime") else: print("Number is not prime") else: print("Enter a number greater than 1") except ValueError: print("Invalid Input. enter valid number") 6. Check if a string is a palindrome. try: num=str(input("Enter a sring:")) if num==num[::-1]: print("Palindrome") else: print("not a palindrome") except ValueError: print("invalid input. Enter a string")
To view or add a comment, sign in
-
Most people learning Python struggle with one thing: Classes. This is not due to how class definitions function or their complexity, but is mainly because they are typically explained in a complicated fashion. I recently shared an article where I break down Python classes in the simplest way possible — from basics to intuition, without unnecessary jargon. Furthermore, understanding class definitions is important in Python and as such is also a requirement when writing scalable/dependable systems. If you're learning Python or transitioning into ML, this will make things much clearer. What concept in Python took you the longest to truly understand? ♻️ Repost if you’re betting on yourself this time. ➕ Follow me, Samith Chimminiyan, for such ML-related content. Learning in public 🚀 #Python #MachineLearning #DataScience #Programming #OOP #LearnToCode #Developers
To view or add a comment, sign in
-
🚀 Python Session 3 – Mastering Control Flow Most beginners learn Python syntax… But the real turning point in programming is learning how to control program logic. That’s exactly what I explored in Session 3 of my Python learning journey. 🐍 These concepts are the backbone of decision-making and automation in Python. 🔎 Key Topics Covered 🧠 1. if Statement – Decision Making Allows your program to execute code only when a condition is true. Example: marks = 72 if marks >= 50: print("You passed the exam") ⚖️ 2. if-else Statement – Two Possible Outcomes Example: age = 17 if age >= 18: print("Eligible to vote") else: print("Not eligible yet") This helps programs choose between two paths. 📊 3. elif Ladder – Multiple Conditions Example: score = 85 if score >= 90: print("Grade A") elif score >= 75: print("Grade B") else: print("Grade C") Used when several conditions must be evaluated. 🔁 4. for Loop – Iteration A for loop repeats a block of code for a fixed sequence of values. Example: for i in range(5): print(i) Perfect for tasks like processing datasets or repeating operations. ⏳ 5. while Loop – Condition-Based Loop Runs as long as the condition remains true. Example: count = 1 while count <= 5: print(count) count += 1 🔄 6. for-else and while-else In Python, loops can include an else block that runs when the loop finishes normally. Example: for i in range(3): print(i) else: print("Loop completed successfully") 🧩 7. pass Statement – Placeholder Sometimes a block of code is required syntactically but not implemented yet. Example: if True: pass pass acts as a temporary placeholder while developing programs. 💡 Why These Concepts Matter Control flow helps developers: ✔ Build logical programs ✔ Automate repetitive tasks ✔ Create intelligent decision-making systems Without control statements, programs would simply run line by line without logic. Drop your answer in the comments 👇 Which concept felt the most interesting while learning Python? 1️⃣ if-else 2️⃣ elif ladder 3️⃣ for loop 4️⃣ while loop 🔄 Repost to help another learner Follow along as I continue documenting my Python learning journey step by step. #Python #LearnPython #PythonProgramming #CodingBasics #ControlFlow #ProgrammingLogic #TechLearning #CodingJourney
To view or add a comment, sign in
-
🐍 Python Practice – Day 3 ( 14 out of 50 questions solved) Continuing my Python learning journey and focusing on strengthening problem-solving skills through small coding exercises. 📌 Problems solved today: 🔹 Count vowels in a string 🔹 Reverse a number 🔹 Print the multiplication table of a number 🔹 Find the factorial of a number 📌 List-based problems: 🔹 Find the largest element in a list 🔹 Find the second largest number in a list 🔹 Remove duplicates from a list Each exercise helps improve my understanding of loops, conditions, lists, and basic Python logic. Consistency is the key, and I’m enjoying the process of learning step by step. Looking forward to tackling more problems tomorrow! 🚀 #Python #PythonLearning #CodingPractice Day 2 Count vowels in a string. try: word=str(input("enter a string")).lower() vowel={'a','e','i','o','u'} s=0 for i in word: if i in vowel: s=s+1 print(s) except ValueError: print("Invalid input. enter string") Reverse a number. try: num1 =str(input("Enter a number: ")) num2=num1[::-1] print(num2) except ValueError: print("invalid input. enter a number") Print multiplication table of a number. try: num=int(input("enter a number")) s=1 mult=0 while s<=10: mult=num*s s=s+1 print(mult) except ValueError: print("invalid input") Find factorial of a number. try: num=int(input("enter a number")) fact=1 while num>0: fact=fact*(num) num=num-1 print(fact) except ValueError: print("invalid input") Find the largest element in a list. try: list1=[1,2,3,4,5,6,7,8,898] print(max(list1)) except ValueError: print("error occured. Please check the code") Find the second largest number in a list. try: list1=[1,2,3,4] largest=max(list1) secondlargest=float('-inf') for i in list1: if i != largest and i >secondlargest: secondlargest=i print(secondlargest) except ValueError: print("error occured. Please check the code") Remove duplicates from a list. try: list1=[1,1,2,2,3,3,4,4,5,5,6,6,7,7,8] set1=set(list1) print(list(set1)) except ValueError: print("invalid operation")
To view or add a comment, sign in
-
How Python Reads Your Code". It explains exactly what happens behind the scenes when Python encounters a simple line of code like r = 1 + 1: Step 1: Chopping It Up First, Python takes your line of code and breaks it down into individual, bite-sized pieces. For the equation r = 1 + 1, it specifically identifies r as the variable name, = as the assignment operator, the first 1 as the first operand, + as the addition operator, and the final 1 as the second operand. Step 2: Structuring & Trimming Once the pieces are separated, Python builds a blueprint by creating a structure that shows exactly how all of these parts connect together. To make sure it works as efficiently as possible, Python then "trims the fat" by removing any unnecessary complexity from this blueprint. Step 3: Analyzing the Ingredients Next, Python looks closely at each piece to identify its specific type—for example, recognizing that the number 1 is an "Integer". After figuring out exactly what kind of data it's holding, Python selects the correct operation (or "tool") needed to handle it. Step 4: The Final Cook Finally, Python executes the operation to process the code and produce your final result. The Process at a Glance The entire workflow boils down to four simple stages: 01 Chopping: Breaking the code into pieces. 02 Structuring: Building a logical blueprint. 03 Analyzing: Identifying data types and the right tools. 04 Executing: Running the code and producing the result.
To view or add a comment, sign in
-
🚀 Day 8 of Learning Python: Error Handling 💻 ✅ Back with a learning update 👉 Today I explored how Python handles errors gracefully using exception handling. This helps prevent programs from crashing and improves user experience. 🔹 Common Python Errors: ZeroDivisionError → Dividing by zeroValueError → Invalid input (e.g., text instead of number)TypeError → Wrong data type usedFileNotFoundError → File does not exist 💡 1. Simple Error Handling try: num = int(input("Enter number: ")) print(10 / num) except: print("Error occurred!")👉 Prevents the program from crashing on invalid input 💡 2. Handling Specific Errors try: num = int(input("Enter number: ")) print(10 / num) except ZeroDivisionError: print("Cannot divide by zero!") except ValueError: print("Please enter a valid number!") 💡 3. Using else try: num = int(input("Enter number: ")) except ValueError: print("Invalid input") else: print("You entered:", num)👉 else runs only when no exception occurs 💡 4. Using finally try: file = open("data.txt") except FileNotFoundError: print("File not found!") finally: print("Execution completed")👉 finally always executes (useful for cleanup) 💡 5. Handling Multiple Errors Together try: a = int(input()) b = int(input()) print(a / b) except (ValueError, ZeroDivisionError): print("Invalid input or division by zero") ⚡ Raising Your Own Error age = int(input("Enter age: ")) if age < 18: raise Exception("You must be 18+") 🔥 Custom Exception (Advanced) class MyError(Exception): pass try: raise MyError("Something went wrong") except MyError as e: print(e) ✅ Key Takeaway: Error handling makes your programs more robust, user-friendly, and professional. #Python #CodingJourney #LearnPython #30DaysOfCode #Programming
To view or add a comment, sign in
-
Python dict: Fast Lookups and How Collisions Are Handled The "dict" is one of the most powerful and frequently used data structures in Python. It provides average O(1) time complexity for lookups, insertions, and deletions. But how does it stay so fast? Under the hood, a Python dictionary is implemented as a hash table. When you insert a key into a dictionary, Python first computes a hash value using the "hash()" function. This hash determines where the key–value pair should be placed in the internal table. However, different keys can sometimes produce the same hash index. This situation is called a hash collision. Python handles collisions using a technique called open addressing. Instead of storing multiple elements in the same bucket (like chained hash tables), Python searches for the next available slot in the table using a probing sequence. The simplified process looks like this: 1. Compute the hash of the key 2. Map the hash to an index in the table 3. If the slot is occupied, probe another position 4. Continue probing until an empty slot or the key itself is found Python dictionaries also maintain performance by resizing the table when it becomes too full. When the load factor increases, the dictionary allocates a larger table and rehashes the existing keys. This design allows Python dictionaries to remain extremely fast even with millions of entries. Understanding how collisions are handled helps explain why "dict" is both efficient and reliable for real-world applications. What’s the most interesting thing you’ve learned about Python dictionaries?
To view or add a comment, sign in
-
Start learning Python by writing code. Not by watching tutorials. Not by saving playlists. Actually writing code. Because Python looks simple on the surface... but the real value comes when you start using it. Most people stop at basics like: print statements loops if-else And then say "I know Python." But real understanding starts when you go deeper. When you learn things like: ●how data structures actually behave ●how functions organize logic ●how OOP helps structure real systems ●how APIs, files, and databases connect to code ●how automation and scripting solve real problems That's when Python starts becoming useful. This PDF is helpful because it doesn't just show syntax. It walks through Python step-by-step - from fundamentals to real-world concepts like APIs, file handling, multithreading, and more. :contentReference[oaicite:0]{index=0) So instead of jumping between random tutorials, you can build understanding in one structured flow. A simple way to use it: 1. Pick one concept 2. Write code for it 3. Modify it and break it 4. Try to apply it in a small use case That's how skills actually stick. Because Python is not about knowing everything. It's about being able to use it when needed. And that only happens through practice. Not passive learning. Save this sheet so you can revisit it while practicing. Comment #Python and I'll send the full PDF. Follow MOHAMMED DILNAWAZ for More..
To view or add a comment, sign in
-
Whether you want to automate repetitive tasks, analyze data, build websites, or dive into machine learning — Python is the perfect starting point. And the best way to start is by getting solid on the fundamentals. In this guide you will learn every basic Python operation through concise explanations, real code examples, and the exact output you can expect to see when you run them. No fluff, no setup headaches — just Python. #Python #DataEngineering https://lnkd.in/g6bvfhHX
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