Day 1: Hello World and Introduction to Python

Day 1: Hello World and Introduction to Python

·

2 min read

Welcome to my 30-day challenge, where I’ll be writing daily blogs related to Python projects. I started this challenge to make myself consistent in learning Python by writing and teaching others. Here’s what we’re covering today:

Today's Focus:

  • Write a simple "Hello, World!" program.

  • Introduce basic syntax, variables, and data types.

"Hello World!"

Basic Syntax

1: Comments

Comments are used to explain code and are not executed by the interpreter.

# This is a single-line comment

"""
This is a
multi-line comment
or docstring
"""

2. Variables and Data Types

Variables store data values, and you don't need to declare their type explicitly.

a = 5          # Integer
b = 3.14       # Float
name = "Joni"  # String
is_active = True  # Boolean

3. Printing Output

print() statement is used to display text on screen.

print("Hello, World!")
print(x)
print(f"My name is {name} and I am {x} years old.")

4. Indentation

Indentation is used to define the level of nesting of control structures. It's critical in Python as it defines the scope of loops, functions, and conditionals (we'll use them in upcoming blogs).

if x > 0:
    print("x is positive")
else:
    print("x is non-positive")

Conclusion:

Today, we focused on the basic syntax of Python. In my upcoming blogs, we'll delve into more advanced topics. Until then, keep learning and keep exploring.

By taking on this challenge, I hope to deepen my own understanding of Python while helping others learn along the way. Feel free to try out the code examples yourself and leave any questions or comments below.