Python Programming: Computer with Numbers from Chapter 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is the suffix for long int?

"L" - 5L -> a long int representation of the number 5. - 2L -> a long int representation of the number 2.

Python floor ( x )

- Mathematical meaning - [ x ] - English meaning - The largest whole number <= x

Python ceil ( x )

- Mathematical meaning - [ x ] - English meaning - The smallest whole number >= x

Python acos ( x )

- Mathematical meaning - arccos x - English meaning - The inverse of cosine x.

Python asin ( x )

- Mathematical meaning - arcsin x - English meaning - The inverse of sine x.

Python cos ( x )

- Mathematical meaning - cos x - English meaning - The cosine of x.

Python e

- Mathematical meaning - e - English meaning - An approximation of e

Python exp ( x )

- Mathematical meaning - e^x - English meaning - The exponential of x.

Python log ( x )

- Mathematical meaning - ln x - English meaning - The natural ( base e ) logarithm of x

Python sin ( x )

- Mathematical meaning - sin x - English meaning - The sine of x.

Python tan ( x )

- Mathematical meaning - tan x - English meaning - The tangent of x.

Python pi

- Mathematical meaning - π - English meaning - An approximation of pi

Python log10 ( x )

- Mathematical meaning - log10 x - English meaning - The common ( base 10 ) logarithm of x

Floating point values

- Numbers that can have fractional parts - A numeric literal that does not have decimal point produces an int value, while a literal that has a decimal point is represented by a float (even if the fractional part is 0).

Whole numbers

- Represented using the integer data type (int for short). - Value of type int can be positive or negative whole numbers.

Computer memory

- composed of electrical "switches," each of which can be in one of two possible states, basically on or off. - each switch represents a binary digit or bit of information.

Round function

- round( ) - rounds a float off to the nearest whole value

What is the largest int that can be represented in 32 bits?

2, 147, 483, 647.

What can Python calculate?

2^30

What kind of bits do PCs use today?

32 bits which means there are 2^32 possible values.

dot notation

<object>.<instance-var> math.sqrt(b * b - 4 * a * c)

How do we fix the overflow error?

By subtracting one from each side

float( )

Convert any data type to a floating point number.

Python provides what and what that can be used to convert numbers in ints and longs, respectively.

Int( ) and long( )

Why do need to remember the proper initialization in the accumulator pattern?

It is a common mistake of programmers.

What is the name of the thing that contains some useful definitions in python and it is a module?

Library

Factorial

Often denoted with an exclamation ("!").

mixed-typed expression

Python will automatically convert ints to floats and perform floating point operations to produce a float results.

set( )

Returns the type after convert to set

Data

The information that is stored and manipulated by computer programs.

Handling Large Numbers: Long Ints

They have unlimited precision

tuple(" ")

Used to a tuple - a sequence of immutable Python objects.

dict( )

Used to convert a tuple of order (key,value) into a dictionary.

list( )

Used to convert any data type to a list type

str( )

Used to convert integer into a string.

Type Conversions

Values of one data type need to be converted into another - average = float(sum) / n

How do we compute with really large numbers?

We use long ints

Accumulator

a variable used in a loop to add up or accumulate a result

abs ( ) operator

absolute value

+ operator

addition

Importing a module makes whatever is defined in it what to the program?

available

Sequence of bits

can be used to represent more possibilities.

int( )

converts any data type to integer

The number of bits that a particular computer uses to represent an int depends on what

design of the CPU.

/ operator

division

** operator

exponentiation

Dot notation of factorial

factorial.main( )

A long int is not a fixed size unlike a what?

float

A long in t is not a fixed size, but expands to accomodate whatever value it what?

holds

how to import factorial?

import factorial

How do you add the math library to a program that is being coded in python?

import math

range ( start, n, step )

it uses step as the increment between numbers.

import math tells Python that we are using what?

math module

To compute square root of x, what do we use?

math.sqrt ( x )

* operator

multiplication

Distinct arrangements for n items

n! = n(n -1)(n-2)...(1).

A value's data type determines what ______________ can be used on it.

operations

range ( start, n )

produces a sequence that starts with the value start and continues up to, but not including, n.

Whenever you use the accumulator pattern, make you you include what?

proper initialization

% operator

remainder

why would converting a float to an int be a dangerous step?

some information (the fractional part) will be lost. - On the other hand, an int can be safely turned into a float just by adding a fractional part of .0.

ints

stored in a fixed-sized binary representation

- operator

subtraction

What special function does python provide that tells us the data type of any value?

type(<data>)


Conjuntos de estudio relacionados

RN Concept-Based Assessment Level 2 Online Practice B

View Set

Chapter 9 and 10 Health Study Guide (Smoking and Alcohol)

View Set

Ch. 17: Drugs, Guns, and Personal Liberty

View Set

Physical Science Exam: Chapter 4

View Set