Skip to ContentGo to accessibility page

1.1 Background

Learning Objectives

By the end of this section you should be able to

  • Name two examples of computer programs in everyday life.
  • Explain why Python is a good programming language to learn.

Computer programs

A computer is an electronic device that stores and processes information. Examples of computers include smartphones, tablets, laptops, desktops, and servers. Technically, a program is a sequence of instructions that a computer can run. Programs help people accomplish everyday tasks, create new technology, and have fun.

The goal of this book is to teach introductory programming and problem solving. Writing programs is a creative activity, inherently useful, and rewarding! No prior background in computer science is necessary to read this book. Many different types of programs exist, as shown in the illustration below. This book will focus on general purpose programs that typically run "behind the scenes."

Checkpoint

Online music streaming

Online music streaming; ch 1, video 1

Concepts in Practice

Computers and programs

1.
How many types of programs were described in the animation?
  1. 3
  2. 4
  3. 5
2.
What type of program will this book explain how to write?
  1. a tool that summarizes an individual's music preferences
  2. a mobile app for managing and sharing playlists of songs
  3. a website that shows the top artists for the past five years
3.
Which of the following devices is an example of a computer?
  1. wired headphones that plug into a smartphone
  2. remote control that pauses or skips the current song
  3. wi-fi speaker that streams music from Amazon
4.
Reading this book requires a strong background in mathematics.
  1. true
  2. false

Exploring further

Later chapters of this book show how to write analysis programs using real data. Example libraries that provide access to online streaming services include Spotipy, Pytube, and Pydora. Python-related tools often have the letters "py" in their name.

The Python language

This book introduces Python, one of the top programming languages today. Leading tech giants like Google, Apple, NASA, Instagram, Pixar, and others use Python extensively.

One reason why Python is popular is because many libraries exist for doing real work. A library is a collection of code that can be used in other programs. Python comes with an extensive Standard Library for solving everyday computing problems like extracting data from files and creating summary reports. In addition, the community develops many other libraries for Python. Ex: Pandas is a widely used library for data analysis.

Another reason why Python is popular is because the syntax is concise and straightforward. The syntax of a language defines how code must be structured. Syntax rules define the keywords, symbols, and formatting used in programs. Compared to other programming languages, Python is more concise and straightforward.

Example 1.1

Hello world in Python and Java

By tradition, Hello World is the first program to write when learning a new language. This program simply displays the message "Hello, World!" to the user. The hello world program is only one line in Python:

print("Hello, World!")

In contrast, the hello world program is five lines in Java (a different language).

public class Hello {
  public static void main(String[] args) {
   System.out.println("Hello, World!");
  }
}

However, conciseness is not the only consideration for which language is used. In different situations different languages may be more appropriate. Ex: Java is often used in Android development.

Checkpoint

Counting lines in a file

Counting lines in a file; ch 1, video 2

Concepts in Practice

Python vs Java syntax

5.
In general, Python programs are _____ than Java programs.
  1. faster
  2. longer
  3. shorter
6.
In the example programs above, what syntax required by Java is not required by Python?
  1. semicolons
  2. parentheses
  3. quote marks

Try It

Favorite song

The program below asks for your name and displays a friendly greeting. Run the program and see what happens. In the error message, EOF stands for End of File.

  • Many of the programs in this chapter expect input from the user. Enter your name in the Input box below the code. Run the program again, and see what changes.
  • Copy the following lines to the end of the program:


    song = input()
    print("Cool! I like", song, "too.")
    print("What is your favorite song?") song = input() print("Cool! I like", song, "too.")

  • The modified program reads two lines of input: name and song. Add your favorite song to the Input box below your name, and run the program again.

The next section of the book will explain how print() and input() work. Feel free to experiment with this code until you are ready to move on.

Citation/Attribution
Reuse and redistribution of this content in digital or print format:
  • This book may not be used in the training of large language models or otherwise be ingested into large language models or generative AI offerings without OpenStax's prior written permission.
  • This book uses the Creative Commons Attribution-NonCommercial-ShareAlike License, which means that you can reuse and modify the material only for noncommercial purposes, must attribute OpenStax, and must distribute any derivative works under the same license.
  • Any commercial printing of this textbook, including using a local or custom printer, must be approved by OpenStax, and proper citation provided.
  • OpenStax-copyrighted images, activities, assessments, and similar components of this book are subject to the same licensing – CC-BY-NC-SA. They can be used for noncommercial purposes with attribution. Commercial use requires permission.
  • Permission requests: Anyone who intends to incorporate this content (including text, images, and other components) into large language models, use it in AI offerings, use it commercially (including in print), and/or has questions about another use case is welcome to complete our reuse request form.
Attribution information
  • If you are redistributing all or part of this book in a noncommercial print format, then you must include on every physical page the following attribution:

    Access for free at https://openstax.org/books/introduction-python-programming/pages/1-introduction

  • If you are redistributing all or part of this book in a noncommercial digital format, then for every page that includes OpenStax content, you must license the derivative work under the same CC-BY-NC-SA license as the original, and include on every digital page view the following attribution:

    Access for free at https://openstax.org/books/introduction-python-programming/pages/1-introduction

Citation information

The information below includes the information needed to generate citations in most major styles (APA, MLA, etc.); you must reformat and organize the information as needed to fit the requirements of the style. Use the information below to generate a citation. We recommend using a citation tool such as this one.

© Apr 23, 2026 OpenStax. Textbook content produced by OpenStax is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike License. The OpenStax name, OpenStax logo, OpenStax book covers, OpenStax CNX name, and OpenStax CNX logo, and Rice University name, and Rice University logo trademarks, or wordmarks are not subject to the Creative Commons license and may not be reproduced without the prior and express written consent of Rice University.

This book utilizes the OpenStax Python Code Runner. The code runner is developed by Wiley and is All Rights Reserved.