Day 1: Python

Divyaraj SinghDivyaraj Singh
2 min read

Today marks Day 1 of my Python journey, and I’m excited to share a few things I’ve learned so far. Whether you're just starting out like me or refreshing your basics, these are some of the most fundamental (yet powerful!) aspects of Python every beginner should know:

1. Block Structure

Python doesn't use curly braces ({}) like other languages. Instead, it relies on indentation to define code blocks. Clean code is happy code!

if True:
    print("Hello, Python!")

2. Adding Comments

Use the # symbol for single-line comments. It helps document your code and improve readability.

# This is a comment
print("This will run")

3. Print Function

The print() function is used to display output on the screen. It’s your first interaction with the console!

print("Welcome to Python!")

4. Escape Sequences

Python supports escape characters like \n (new line) and \t (tab) for formatting strings.

print("Hello\nWorld")
print("Name:\tPython")

5. Variables

You don’t need to declare a variable type. Just assign a value and Python figures it out!

name = "Alice"
age = 25

6. Dynamic Nature

Variables in Python are dynamically typed – they can switch types anytime.

x = 10
x = "Now I'm a string"

7. id() Function

Use id() to check the memory address of an object – useful when exploring how Python handles variables.

print(id(x))

8. Identity Operator

Use is and is not to check if two variables point to the same object, not just equal values.

a = [1, 2]
b = a
print(a is b)  # True

9. String Formatting

Python makes it easy to format strings using .format() or the more modern f-strings.

name = "Alice"
print("Hello, {}".format(name))
print(f"Hello, {name}")

10. input() Function

Want to get input from the user? input() always returns a string.

user_input = input("Enter your name: ")
print(f"Welcome, {user_input}!")

Soon we will Publish short articles on “How variables work in Python ?” & “6 ways to format strings in Python”

0
Subscribe to my newsletter

Read articles from Divyaraj Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Divyaraj Singh
Divyaraj Singh