← Back to all guides
🐍

Your First Python Script

Write your first real Python code in 10 minutes. No experience needed — just vibes.

Pythonbeginner7 min read

Your First Python Script

Python is probably the friendliest programming language out there. It reads almost like English, it doesn't yell at you with semicolons, and it's used for everything from web apps to AI to automating boring spreadsheet tasks. Let's write your first script.

Why Python? (Like, Why Would a Real Person Use This?)

Before we write any code, here's why Python matters beyond tutorials:

  • Automating your job: People use Python to auto-generate reports, clean up spreadsheets, send batch emails, and rename thousands of files. One woman automated her entire Monday morning data entry and spent the time getting coffee instead.
  • Data analysis: If you've ever wanted to answer "what are my top-selling products?" or "when do I get the most Instagram engagement?" — Python can crunch those numbers from a CSV in seconds.
  • Web scraping: Want to track price drops on a product? Python can check the website every hour and text you when it goes on sale.
  • AI and machine learning: ChatGPT, image generators, recommendation algorithms — most AI is built with Python. If you want to understand or build AI, Python is the language.
  • Building websites: Instagram's backend is Python (Django). Pinterest, Spotify, and Dropbox also use it.
  • Career-wise: Python developers are in high demand and it's one of the highest-paid programming languages. But more importantly, it's a skill that makes you dangerous in ANY career — marketing, finance, healthcare, education — because you can automate things other people do manually.

It also happens to be great for beginners:

  • It reads like plain English (no weird symbols everywhere)
  • You get results fast (no complicated setup)
  • It's used everywhere (Google, Netflix, NASA, Instagram)
  • The community is massive (so you can always find help)

💬 Denise says

I started with JavaScript, and when I tried Python for the first time I literally said out loud, "Wait... that's it?" It felt too simple to be real. But that's the beauty of it — Python doesn't make you jump through hoops.

Hello, World!

Every programmer's first program. Here's yours:

1# This is your first Python script!
2print('Hello, world!')
3
4# You can print anything:
5print('My name is Denise')
6print('I am learning Python')
7print('And it is not scary at all')

Variables: Labeling Your Stuff

A variable is just a name you give to a piece of data. Think of it as a labeled jar:

1# Creating variables (labeled jars)
2name = 'Denise'
3age = 28
4favorite_color = 'lavender'
5loves_coffee = True
6
7# Using them
8print('Hi, my name is ' + name)
9print('I am ' + str(age) + ' years old')
10print('My favorite color is ' + favorite_color)

💡 Pro tip

Python variable names use snake_case (words separated by underscores). So it's favorite_color not favoriteColor. This is just a Python convention — it's not wrong to do it differently, but all Python developers do it this way.

Making Decisions with If/Else

Your code can make choices:

1temperature = 75
2
3if temperature > 80:
4print('It is HOT. Stay inside.')
5elif temperature > 60:
6print('Perfect weather! Go outside.')
7else:
8print('Bundle up, it is chilly.')
9
10# This would print: 'Perfect weather! Go outside.'
11# Because 75 is greater than 60 but not greater than 80

⚠️ Heads up

Indentation matters in Python! Unlike most languages, Python uses spaces (usually 4) to know what code belongs inside an if block, loop, or function. If your code isn't working, check your indentation first.

Lists: Collections of Things

A list is exactly what it sounds like — a list of items:

1# A list of your favorite things
2favorites = ['coffee', 'Python', 'rainy days', 'lo-fi music']
3
4# Access items by position (starts at 0, not 1!)
5print(favorites[0]) # 'coffee'
6print(favorites[2]) # 'rainy days'
7
8# Add something new
9favorites.append('sushi')
10
11# How many items?
12print(len(favorites)) # 5
13
14# Loop through every item
15for thing in favorites:
16print('I love ' + thing)

Your First Useful Script

Let's build something actually useful — a simple tip calculator:

1# Tip Calculator
2bill = 45.50
3tip_percent = 20
4
5tip_amount = bill * (tip_percent / 100)
6total = bill + tip_amount
7
8print('Bill: $' + str(bill))
9print('Tip (' + str(tip_percent) + '%): $' + str(round(tip_amount, 2)))
10print('Total: $' + str(round(total, 2)))
11
12# Output:
13# Bill: $45.5
14# Tip (20%): $9.1
15# Total: $54.6

Getting User Input

Make your scripts interactive:

1# Ask the user questions
2name = input('What is your name? ')
3food = input('What is your favorite food? ')
4
5print('Nice to meet you, ' + name + '!')
6print('I also love ' + food + '!')
7
8# When you run this, it will pause and wait
9# for the user to type something

How to Run Python

  1. Install Python: Download from python.org (it's free)
  2. Write your code: Save it as my_script.py (the .py extension)
  3. Run it in the terminal: python my_script.py

Or use an online editor like repl.it — no installation needed!

💡 Pro tip

If you have VS Code, install the Python extension. Then you can write and run Python right inside your editor — just click the play button at the top right. Super convenient.

Quick Recap

  • Python reads like English — no semicolons, no curly braces
  • print() shows stuff on screen
  • Variables are labeled jars: name = 'Denise'
  • if/elif/else for making decisions
  • Lists hold collections: ['item1', 'item2']
  • for loops go through items one by one
  • input() lets users type responses
  • Indentation matters!

💬 Denise says

You just wrote real Python. Not fake "hello world and goodbye" Python — you built a tip calculator, you worked with lists, you got user input. These are the building blocks of every Python program ever. Automation scripts, web scrapers, AI models — they all start with the exact concepts you just learned. You're doing amazing.

📸

Photo coming soon ✨

🚀

Want to keep going?

Tell me what you want to build next and I'll help you write the code.

Start Building ✨