Skip to main content
02 Introduction to data

Here's the translated markdown:


Data Types

image-20231214105801217

1. Numeric Types: int, float

1.1 Code Examples

  1. Integer
int_num = 1
t = type(int_num)
print(int_num)
print("int num type is: >>>", t)
print("Detecting data type directly and outputting", type(int_num))

#output
1
int num type is: >>> <class 'int'>
Detecting data type directly and outputting <class 'int'>

CindyOriginal...About 5 minpython notebooknotespython
03 Newmeric Type

Here's the translated markdown:


1. Characteristics of Numeric Types

image-20231216151331535
In [3]: 1 + 1
Out[3]: 2

In [4]: 1 + 1.0
Out[4]: 2.0

In [5]: 2 -1
Out[5]: 1

In [6]: 2 - 1.0
Out[6]: 1.0

In [7]: 2 * 2
Out[7]: 4

In [8]: 2* 2.0
Out[8]: 4.0

In [9]: 9/3
Out[9]: 3.0

# The result is a float if one of the elements is a float, with the highest precedence.

# Division involves precision issues, resulting in a float.

CindyOriginal...About 4 minpython notebooknotespython
01 Variable

Sure, here's the translated markdown:


1. Understanding Variables - Examples from Daily Life

1.1 What is a Variable

  • Vari: Change
  • Able: Capacity

1.2 An Example

Let's say you're the class monitor and you need to compile the monthly test scores of each student in the class. Each month's score will be recorded on a paper, listing each student's score, for instance:


CindyOriginal...About 5 minpython notebooknotespython