1.2 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.”

The Python language
This book introduces Python (https://openstax.org/r/100python), 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.

Leave a Reply