Start Your Python Course

For More Lessons Download Our Mobile apps From Play Store

Download Mobile App

Welcome to PythonSchool — a beginner-friendly resource designed to help you learn Python step by step. Python is one of the most popular programming languages used in web development, data science, automation, and more.

Why Learn Python?

  • Simple and beginner-friendly syntax
  • Large community and extensive libraries
  • Used by companies such as Google, Netflix, and NASA
  • Great for automation, AI, data analysis, and web development

Lesson 1: Python Basics

1.1 The print() Function

The first step in learning any programming language is displaying output. In Python, you can use the print() function:

print("Hello, World!")

This will display text on your screen. Try changing the message and running it again!

1.2 Variables

Variables store data values. Python automatically detects the type — you do not need to declare it manually.


username = "Alex"
age = 29
is_student = False

print(username)  # Output: Alex
      

Tip: Use descriptive variable names to make your code easy to understand.

1.2 Naming Variables

A valid variable name must start with a letter or an underscore (_), not a number. Variable names are case-sensitive and can contain alphanumeric characters.

Examples of valid variable names:

favorite_fruit = "Orange"
_favoritefruit = "Orange"
favoriteFruit = "Orange"
favorite01fruit = "Orange"
      
Pro Tip ✍️: You can change the value of a variable by assigning it a new one:

favorite_fruit = "Lemon"
print(favorite_fruit)

# Change the value
favorite_fruit = "Orange"
print(favorite_fruit)
      

1.3 Syntax and Indentation

Python uses indentation (spaces or tabs) to define code blocks. Proper indentation is essential.


if 7 < 15:
    a = 15
    print("You have fewer points")
      

Incorrect indentation causes an error:


if 7 < 15:
   a = 15
        print("This produces an error!")
      

1.4 Comments in Python

Comments are ignored by Python and help explain your code.


x = 5
y = 7
print(x + y)

# print(y/x)  -> This line is a comment and will not run
      
Tip: Use comments to explain why your code works, not just what it does.

Multi-line Comments:


# Using multiple hash (#) symbols
# I like
# oranges and
# bananas

"""Using triple quotes also works
as long as the string is not assigned
to a variable."""
      

Follow our official learning channel for updates:

Follow

Try a Simple Exercise

Use print() to display your name and age on separate lines.


Quick Quiz

1. What function is used to print text in Python?




2. How do you start a comment in Python?




Next Lesson

Continue to the next topic to learn more about Python data types:

→ Data Types