Day 1: Diving into Python Basics – Printing, Input Functions, Variables, and More!


Greetings, fellow learners!
Welcome to Day 1 of my 100 Days of Python journey! Today, I began my deep dive into Python, starting with some of the most fundamental concepts that will lay the foundation for everything to come. With this journey, my goal is to learn by doing, focusing on hands-on practice through the projects that Angela Yu provides in her course. Here’s what I learned today.
What I Learned Today
Printing and String Manipulation: The first concept I tackled was how to use the
print()
function to display messages and manipulate strings. This is a basic yet essential skill, as it’s one of the first things you need to understand to interact with your program.# Printing messages with the print() function print("Hello, world!") # Output: Hello, world!
String manipulation is also key. I practiced string concatenation and learned how to handle special characters using escape sequences.
# String concatenation name = "John" age = 25 print("My name is " + name + " and I am " + str(age) + " years old.") # Output: My name is John and I am 25 years old. # Using escape characters print("This is a newline\nand this is a tab\tcharacter.")
Input Function: The
input()
function was the next thing I explored. This function allows me to capture user input, making the program interactive. I practiced usinginput()
to take data from users and display it dynamically.# Using input() to receive user input name = input("Enter your name: ") print("Hello, " + name + "!") # Combining input() and print() for interactive messages age = input("Enter your age: ") print("You are " + age + " years old.")
Variables and Swapping Values: Today, I also delved into variables—how to declare them and manipulate their values. A neat trick I learned was how to swap values between two variables using multiple assignments, which was both efficient and simple to implement.
# Variable declaration and assignment a = 10 b = 20 # Swapping values using multiple assignment a, b = b, a print("After swapping:") print("a =", a) # Output: a = 20 print("b =", b) # Output: b = 10
Commenting and Variable Naming Practices: The importance of writing clean and readable code has become clear today. I learned about the importance of good variable naming practices and how to use comments to make my code more understandable.
# Example of good variable naming and commenting # Calculate the area of a rectangle length = 5 width = 3 area = length * width print("The area of the rectangle is:", area) # Output: The area of the rectangle is: 15
Join Me!
I invite you to follow along as I continue my Python journey. Whether you're an experienced developer or starting, you can join me in exploring these concepts. Stay tuned for daily updates, challenges, and victories!
Feel free to share your thoughts and ask questions in the comments section. I’m excited to have you on this learning adventure with me.
Conclusion
Day 1 has given me a solid foundation in the basics of Python, and I’m already looking forward to what’s next. I’m starting to understand how these simple building blocks come together to create more complex programs. With my first few steps in Python now behind me, I can’t wait to dive deeper into more exciting concepts!
Until tomorrow, happy coding!
Subscribe to my newsletter
Read articles from Ayushi singla directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
