파이썬S1: 자료형(Data Types)

소바·2022년 9월 2일
0

파이썬

목록 보기
1/5

Data Types

Fundamental Data Types

Now these data types are called the fundamental data types.

a program is simply instructions that tell a computer what to do.

It's all about storing information or a data type and modifying that information.

We're taking actions on these data types.

So the two crucial steps when learning a programming language is that, well, we have these data types that we need to understand that exist in a language, and then we need to learn how we can manipulate the data, create store, read change, remove this data from the machine.

Classes -> custom types

Specialized Data Types -> Module

There are specialized data types that we can use from what we call modules.

None

As the name suggests, means nothing.
It's the absence of value.
It's kind of like the idea of zero in math.

Fundamental Data Types

numbers

int (= integer)

An integer is, well, a number.

float ( =A floating point number)

float is simply a number with a decimal point.

power of (**)

So this means to the power of so two to the power of two.

round down (//)


We also have the double divide.
This actually returns an integer.
This gets rounded down to a integer.

modulo (%)

Modulo is used to represent what's the remainder of this division.
So if I divide 5 by 4, the remainder of this division will be 1.

Why there is a type of Data?


Why do we need to make this distinction in programming and specifically in Python?

Well, it's because a float takes up actually a lot more space in memory than an integer.

Because remember this number, the number six, this needs to get stored in memory on our machine. And remember that machines don't really understand this.

The idea is that we need more memory to store a number like this than a number like this.

And they store this number in something called a binary(이진법) or binary numbers, which is 0 and 1.

Now, the problem is when you have a decimal places like zero point or let's do 10.56, it's hard to represent that in a binary number, 0 and 1.

So a floating point number essentially stores these numbers in two different location, one for the 10 and one for 56.

math functions

math functions

round

abs (absolute value of the argument)

that I get abs here and ABS returns the absolute value of the argument.

operator precedence

augmented assignment operator(증강 대입문)

string


And this skull augmented assignment operator, it's a shorthand of us doing something like this.

string concatenation(=connection)

Type conversion(=change)

Type conversion 응용


숫자에서 문자를 빼려고 하니 에러가 난다.
type을 string에서 integer로 변환해줘야한다

Escape Sequence

formatted strings( = f-string)

So if you think of a bookshelf, each one of these is ordered in a different part of the bookshelf, but one after another.

string index

Immutability(= permanence)

Built-in functions & methods

A built in function

A built(=included) in function Functions that come with Python and had the syntax of the word that was highlighted in blue, and then we used brackets to perform some action on a data type.

methods


https://www.w3schools.com/python/python_ref_string.asp
However, Python also has this idea of methods and methods are similar to functions, but they they are owned by something.

So for example, in Python we have string methods.

So these are methods or actions that only strings can perform.
instead of just the word with the curly brackets, it usually has a dot in front of it.

With this python gives us automatic tools that we can use on strings.

booleans ( bool)

Booleans represent this idea of true and false, which in programming is kind of like saying 0 and 1. They're logical values.

변수이용하기

profile
소바보이

0개의 댓글