sec01 - Variables and Data Types [Overview]

What you will learn in this section

In this section, you will learn the following topics.

  1. Variables
  2. Integers and Floating-Point Numbers
  3. Strings

Details will be explained in each lecture, but this page provides an overview of each topic.

Variables

A variable is like a box that temporarily stores information, such as numbers or text. You will learn how to assign (temporarily record) numerical or textual information to variables and how to overwrite values that have been assigned once. Additionally, you must assign names to variables to identify them, and Python has naming rules for variables, which you will also learn about.

Temporary storage

Assigning a value to a variable means storing information in the “memory” component of a PC. Unlike HDDs and SSDs, memory is not a permanent storage device. Data stored in memory is lost when the application (program) is closed or the PC is turned off. Additionally, the value of a variable may be erased during program execution. For this reason, I emphasized the phrase “temporarily stored” in the previous explanation.

If you want to permanently store data, you need to save it in a format like text data on an HDD or SSD. (Just like when you saved “hello_world.py”!)

The method for saving data as a file will be explained in a dedicated lecture. For now, remember that “values assigned to variables are temporary records, and a different method is required to permanently store data.”

Integers and Floating-Point Numbers

You will learn how to handle numbers and perform arithmetic operations with integers and floating-point numbers.

  • Integer: Numerical values such as “10”, ‘0’, and “-5”
  • Floating-Point Numbers: Numerical values such as “0.5”, “0.0”, and “-2.5”
  • Conversion between floating-point numbers and integers
  • Arithmetic operations: Addition, subtraction, multiplication, division, exponentiation, division with remainder, assignment operators, etc.
  • Round function and mathematical functions: Introduction to functions such as rounding and finding the absolute value.

Strings

Learn about string definitions, concatenation methods, and more.

In programming, text information (data) is called a “string.” Some programming languages refer to this as a “character” (abbreviated as ‘char’), but Python uses the term “string” consistently.

  • String definition
  • String operations: Methods for extracting or concatenating parts of strings
  • String methods: Functions (methods) specific to “objects”
おすすめの記事