1 Getting Started With Python
1.1 What is Coding?
- Coding is telling a computer what to do, step by step, using a special language.
- Coding is super fun!
- You can make your own games and stories.
- You can solve puzzles and problems.
- Coding helps you use computers to solve real-world problems.
- Learning to code is a great skill for everyone, especially kids.
- Coding can even help you get a cool job in the future!
Fun Fact: Python is used by companies like Google and NASA!
1.2 Why Python?
- Python is a real programming language, and it’s also easy to learn!
- Python is easy to read and write, almost like English.
- Python is one of the most popular and fastest-growing languages.
- Check the TIOBE index, which shows the popularity of programming languages.
- See the growth rate on Stack Overflow.
- Python is also very popular on GitHub programming-languages. (top10 usage and top10 languages)
- Check out Google Trends to see how popular Python is.
- Python is perfect for beginners and non-professional programmers.
- Great for small projects.
- Easier to use than languages like C++, C#, or Java.
1.3 Getting Started with Python
1.3.1 Install Python
- Go to the Python download page, download, and install Python 3.1x or newer.
- Windows users:
- During installation, make sure to check the box that says Add Python to PATH.
- You can read this installation guide for Windows.
- Mac users:
- You can read this installation guide for Mac.
- Mac may already have Python 3 installed. Check your version to be sure.
- Check if Python is installed:
- Open a command prompt (Windows: press
Win + R
, typecmd
, and press Enter) or terminal (Mac). - Type
python --version
and press Enter. You should see the version number printed. - Type
python
and press Enter to start the Python shell. - Try typing
3+4
and press Enter. You should see the result7
. - Type
exit()
and press Enter to exit the Python shell.
- Open a command prompt (Windows: press
1.3.2 Install a Python Editor
There are many Python editors available. Here are a few popular ones:
- VS Code
- VS Code is a powerful editor for many programming languages.
- Download VS Code.
- Follow this guide to install Python Extensions in VS Code.
- Get started with Python in VS Code here.
- Try VS Code online (new).
- Python IDLE
- IDLE comes with Python. Open it by searching for “IDLE” in the Start menu.
- Learn how to use IDLE.
- PyCharm Edu
- PyCharm Edu is a special editor to help you learn Python.
- Download PyCharm Edu.
In this guide, we will use VS Code because it is easy to use, has many features, and supports not only Python but also other languages.
1.4 Your First Python Code
Let’s write your very first Python program!
# hello_world.py
# This line prints a message to the screen
print("Hello world!")
# This line asks the user for their name
name = input("What is your name?\n")
# This line prints a personalized greeting
print("Hi,", name)
Try it out! Write this code in your editor and see what happens.
Activity: Make It Your Own!
- Change the message to say something different.
- Ask the user for their favorite color and print a message with it.
color = input("What is your favorite color?\n")
print("Wow!", color, "is a great color!")