# Day 4 - Our First Python Program

* * *

![](https://cdn.hashnode.com/uploads/covers/664f77938fc1f806b829b90b/49137e3c-d8e3-4c47-bf6c-8b1651af707b.jpg align="center")

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:

```python
print("Hello World!")
```

Output:

```text
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:

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

Output:

```text
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:

```python
print(753)
```

Output:

```text
753
```

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

Compare:

```python
print(753)
```

with:

```python
print("753")
```

Both display:

```text
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:

```python
print("Hello World!", 753)
```

Output:

```text
Hello World! 753
```

Python separates the values with a space by default.

We can also print several values:

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

Output:

```text
Python is awesome
```

* * *

# Printing Calculations

Python can also perform calculations inside `print()`.

For example:

```python
print(753 * 3510)
```

Python evaluates the multiplication first and then prints the result.

Output:

```text
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:

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

Output:

```text
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.

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

Output:

```text
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:

```python
print("First")
print("Second")
print("Third")
```

The output will be:

```text
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:

```python
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:

```python
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:

```python
print(Hello World!)
```

Correct:

```python
print("Hello World!")
```

Text should generally be enclosed in quotation marks.

* * *

## 2\. Missing Parentheses

Incorrect:

```python
print "Hello World!"
```

Correct:

```python
print("Hello World!")
```

Python 3 uses parentheses with the `print()` function.

* * *

## 3\. Incorrect String Quotes

Incorrect:

```python
print("Hello World!)
```

The opening and closing quotes must match.

Correct:

```python
print("Hello World!")
```

* * *

## 4\. Writing a Calculation as Text

Compare:

```python
print(10 + 5)
```

Output:

```text
15
```

with:

```python
print("10 + 5")
```

Output:

```text
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 text

```python
print("Hello World!")
```

### Print a number

```python
print(753)
```

### Print multiple values

```python
print("Hello", 753)
```

### Print a calculation

```python
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] 

* * *
