# Data Types Data Types Every program must deal with data PowerPoint Presentation, PPT - DocSlides

2018-10-28 10K 10 0 0

##### Description

The data is usually described as a certain type. This type determines what you can do with the data and how the data is stored. In Python basic types are integers (. int. ), floating point (float), strings and Booleans. ID: 699809

**Direct Link:**Link:https://www.docslides.com/celsa-spraggs/data-types-data-types-every-program-must-deal-with-data

**Embed code:**

## Download this presentation

DownloadNote - The PPT/PDF document "Data Types Data Types Every program must..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

## Presentations text content in Data Types Data Types Every program must deal with data

Data Types

Slide2Data Types

Every program must deal with data

The data is usually described as a certain type

This type determines what you can do with the data and how the data is stored

In Python basic types are integers (

int

), floating point (float), strings and Booleans

The first two are numeric and can be used in arithmetic, the last two are not

Slide3Integers vs. Floating point

Integers are numbers which have no decimals, no fractions

They can be positive, negative, zero

Python can handle numbers of

very,

very large magnitude

Floating point numbers are ones which have fractions, like 3.14 and 2.0 and 5.2983841983

They are stored differently in the computer and their arithmetic is done differently

Slide4Floating point numbers - storage

Each floating point number is stored in several pieces. You can think of one as being written in scientific notation, like

3.592 x 10

2

= 359.2

In Python this is written as 3.592e2 (the base is assumed to be 10)

The 3.592 is the

mantissa

The 2 is the power or exponent – it can be positive or negative. Positive powers make numbers larger, negative powers make numbers smaller (towards zero)

Example: 4.923e-3 = 0.004923

Example: 7.2341e10 =

72341000000

Slide5Floating point numbers – arithmetic

When you add numbers with decimals together, you must “align the decimals” so you are adding tenths to tenths, hundredths to hundredths and so on

The computer does the same thing behind the scenes

So floating point arithmetic is usually slower than integer arithmetic

Floating point numbers also have an inherent error in them, just because a lot of numbers cannot be stored precisely in the machine (think of pi or 1/3). Even 0.1 is not precise inside the computer – in binary it is a repeating decimal!

Most calculations are not too much affected by this but you should be aware of it. If your work depends on many decimal places of accuracy, be careful how you use floating point numbers!

Slide6Strings

These data items are delimited by quotes, either single quotes (‘) or double quotes (“)

(Delimited by means that they are enclosed by the quotes, marked off by the quotes)

We will use them in many ways

simply as labels “Total of numbers”

variables like names and address

input data

Examples: “Joe”, “12345923 adfa123.s8234&*”, “”, ‘”hi” he said’

Slide7Booleans

Named after George

Boole,

English

mathematician

, logician

Created Boolean algebra, a two-valued logic based on True and False

The basis of all computer circuits (see EE 280)

In Python the Boolean constants are True and False – note that these are not strings – no quotes

They can be assigned to variables, they can be output

They are used most often with if statements, chapter 6