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

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, where I began exploring foundational concepts and set the stage for mastering this versatile language.

What I Learned Today

1. Printing and String Manipulation: Today, I learned how to use the print() function for displaying messages and practiced string manipulation techniques like concatenation and using escape characters.

# Printing messages with the print() function
print("Hello, world!")  # Output: Hello, world!

# String concatenation
name = "Rishabh"
age = 30
print("My name is " + name + " and I am " + str(age) + " years old.")  # Output: My name is Rishabh and I am 30 years old.

# Using escape characters
print("This is a newline\nand this is a tab\tcharacter.")  # Output: This is a newline
                                                            #         and this is a tab   character.

2. Input Function: The input() function allowed me to receive user input during program execution, enabling the creation of interactive applications by combining input() within print() statements to prompt users and display their input efficiently.

# 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.")

3. Variables and Swapping Values: Today, I learned how to declare and manipulate variables in Python, including a neat trick for efficiently swapping variable values using multiple assignments.

# 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

4. Commenting and Variable Naming Practices: I learned the importance of clear commenting and variable naming to keep my code readable and maintainable.

# 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 explore Python programming, whether you're experienced or just starting out, and stay tuned for daily updates, challenges, and victories, while checking out my GitHub repository for all the shared code.

Conclusion

Day 1 has set the stage for an exciting journey ahead. With a solid foundation in Python basics now established, I eagerly look forward to what the coming days will bring. Thank you for joining me on this adventure—I can't wait to see where Python takes us next!

Until tomorrow, happy coding!

Did you find this article valuable?

Support Rishabh Mishra by becoming a sponsor. Any amount is appreciated!