Skip to main content

Command Palette

Search for a command to run...

Day 4 - Our First Python Program

Updated
6 min readView as Markdown
Day 4 - Our First Python Program
S

🚀 Passionate DevOps Engineer with expertise in cloud computing, CI/CD, and automation. Skilled in Linux, Docker, Kubernetes, Terraform, Ansible, and Jenkins. I specialize in building scalable, secure, and automated infrastructures, optimizing software delivery pipelines, and integrating DevSecOps practices. Always exploring new ways to enhance deployment workflows and bridge the gap between development and operations.


Welcome to Day 4 of 100 Days of Python!

So far, we have learned:

  • What programming is

  • What Python is

  • Where Python is used

  • What modules and packages are

  • How pip is used to install Python packages

Today, we are finally going to write our first Python program from scratch.

It may look very simple—and it is.

But every Python developer has to start somewhere.

Today, that starting point is the print() function.


The print() Function

The print() function is used to display information on the console.

The simplest example is:

print("Hello World!")

Output:

Hello World!

Here:

  • print is a built-in Python function.

  • "Hello World!" is a string.

  • The value inside the parentheses is passed to print().

  • Python displays the result on the console.


Printing Text

We can use print() to display text.

Text in Python is written inside quotes.

For example:

print("Hello World!")
print("Welcome to Python!")
print("I am learning Python.")

Output:

Hello World!
Welcome to Python!
I am learning Python.

Each print() statement normally displays its output on a new line.


Printing Numbers

We can also print numbers directly.

For example:

print(753)

Output:

753

Notice that we don't need quotation marks around a number.

Compare:

print(753)

with:

print("753")

Both display:

753

However, they represent different types of values.

  • 753 is a number.

  • "753" is text (a string).

We will learn more about data types later.


Printing Multiple Values

The print() function can accept multiple values separated by commas.

For example:

print("Hello World!", 753)

Output:

Hello World! 753

Python separates the values with a space by default.

We can also print several values:

print("Python", "is", "awesome")

Output:

Python is awesome

Printing Calculations

Python can also perform calculations inside print().

For example:

print(753 * 3510)

Python evaluates the multiplication first and then prints the result.

Output:

2643030

This is one of the reasons programming languages are useful: we can give the computer an expression, and it can perform the calculation for us.

Other examples:

print(10 + 5)
print(20 - 8)
print(6 * 7)
print(20 / 4)

Output:

15
12
42
5.0

We will learn operators and calculations in more detail later.


Our First Python Program

Let's combine everything we learned today.

print("Hello World!", 753)
print(753)
print("Bye")
print(753 * 3510)

Output:

Hello World! 753
753
Bye
2643030

This is a very small program, but it already demonstrates several important ideas:

  1. Printing text

  2. Printing numbers

  3. Printing multiple values

  4. Performing a calculation

  5. Executing multiple statements in sequence


How Python Executes the Program

Python executes our program from top to bottom.

Consider:

print("First")
print("Second")
print("Third")

The output will be:

First
Second
Third

Python starts with the first statement, executes it, moves to the next statement, and continues until the program ends.

This sequential execution will become extremely important when we start learning conditions, loops, functions, and more advanced concepts.


A Small Challenge

Now it is your turn!

Write a Python program that prints a short poem.

For example, the structure could be:

print("Your poem goes here")
print("Another line of your poem")
print("Another line of your poem")

You can choose any poem you like.

The purpose of this exercise is not to write complicated code.

The purpose is to practice writing and executing Python code yourself.


Challenge: Create Your Own Output

Try creating a small program that prints:

  • Your name

  • A programming-related message

  • A number

  • A calculation

For example:

print("My name is Sritesh.")
print("I am learning Python.")
print(100)
print(25 * 4)

Try changing the values and see what happens.


Common Mistakes

1. Forgetting Quotes Around Text

Incorrect:

print(Hello World!)

Correct:

print("Hello World!")

Text should generally be enclosed in quotation marks.


2. Missing Parentheses

Incorrect:

print "Hello World!"

Correct:

print("Hello World!")

Python 3 uses parentheses with the print() function.


3. Incorrect String Quotes

Incorrect:

print("Hello World!)

The opening and closing quotes must match.

Correct:

print("Hello World!")

4. Writing a Calculation as Text

Compare:

print(10 + 5)

Output:

15

with:

print("10 + 5")

Output:

10 + 5

The first performs a calculation.

The second simply prints the characters as text.


Quick Revision

What is print()?

print() is a built-in Python function used to display information on the console.

print("Hello World!")
print(753)
print("Hello", 753)
print(753 * 3510)

Python execution order

Python normally executes statements from top to bottom.


Day 4 Takeaways

Today we learned:

  1. How to write a basic Python program.

  2. How to use the print() function.

  3. How to print text.

  4. How to print numbers.

  5. How to print multiple values.

  6. How to perform calculations inside print().

  7. How Python executes statements sequentially.

  8. How to create a simple Python program independently.


Final Thought

Our first program is intentionally simple.

That's okay.

Every large Python application—from automation scripts to Machine Learning systems—is ultimately built from smaller programming concepts.

Today we wrote a few print() statements.

Soon, we will learn how to make our programs store information, make decisions, repeat tasks, accept input, work with data, and solve real problems.

For now:

We have officially written our first Python program.

Day 4 complete. 🚀


📂 Day 4 Resources

All notes and code for this day are available in the GitHub repository:

https://github.com/SriteshSuranjan/100-Days-of-Python/tree/main/04-Day04-Our-First-Program


100 Days of Python

Part 13 of 16

A structured 100-day journey to learn Python from the fundamentals to advanced concepts through consistent practice and hands-on coding. This series covers Python concepts step by step, including syntax, variables, data types, control flow, functions, data structures, object-oriented programming, exception handling, modules, file handling, libraries, and more. Each day includes clear notes, practical examples, and coding exercises to make learning easier and provide a useful reference for revision. The goal is to build a strong Python foundation that can be applied to automation, software development, data analysis, Artificial Intelligence (AI), Machine Learning (ML), and other areas of technology. Follow along, practice consistently, and build your Python skills one day at a time.

Up next

Day 3 - Python Modules and pip

Welcome to Day 3 of 100 Days of Python! On Day 1, we learned what Python is and where it is used. On Day 2, we explored the different kinds of applications that can be built with Python. Today, we are