DEV Community

loading...
Cover image for How to Write a Simple Python Program

How to Write a Simple Python Program

jones268 profile image jones268 ・2 min read

This tutorial will teach you how to write a simple Python program. We will begin by explaining what a Python program is and then move on to cover various aspects of syntax, which is the structure of the language.

What is Python?

Python is a programming language that is becoming more and more in demand. It’s an open source language that, as you see below, allows you to create anything from games to web applications using only text. Python is a language that has many unique features, such as the following:

  • Python is free.
  • Python runs on Linux, OS X, and Windows.
  • Python allows you to work with files and folders directly from your computer.
  • Python is a high level language, which means that it was designed to be easy for humans to read and write.
  • Python statements are made up of small parts that can be joined together. They look just like English words, so they are easy to read and understand.

Here are some other things that you can do in Python:

  • Write and install your own computer game in an hour or less.
  • Automatically download an image and show it on your website.
  • Make a GUI app? Yes, you can create desktop apps with Python scripts using pyqt or tkinter

Hello world

Hello pythonistas,

This is just a simple tutorial on how to write your first program in Python.

Let me just start this by saying that Python is a very simple programming language to learn. You don't have to be a programming expert to understand it and use it.

Pyhton is also a great language to get started with coding because it's easy to read, write, and maintain.
All you really need is some background in computer science, or at least a basic understanding of how computers work.
Here are the steps you'll need to take to write your first python program:

First, open up your text editor of choice (or an IDE) and save it as "hello.py" (Note: Not .txt). You can use any text editor you want such as notepad or gedit. I personally use vim but you can use any text editor, or an IDE like PyCharm.

The file contents should be:

print("Hello world")
Enter fullscreen mode Exit fullscreen mode

The next step is to run it with the command

python hello.py
Enter fullscreen mode Exit fullscreen mode

It should output the hello world message to your computer. If you get an error it's because Python is not installed.

Discussion (0)

pic
Editor guide