Python Review.

28
Python Review

description

Iteration Start Stop Increment Number for x in sequence: print x Start: x = sequence[0] Stop: x = sequence[len(sequence) – 1] Increment: values in sequence Number: len(sequence)

Transcript of Python Review.

Page 1: Python Review.

Python Review

Page 2: Python Review.

IterationStartStopIncrementNumber for x in sequence:

print x

Start: x = sequence[0]Stop: x = sequence[len(sequence) – 1]Increment: values in sequenceNumber: len(sequence)

Page 3: Python Review.

IterationStartStopIncrementNumber for x in range(10):

print x

Start: x = 0Stop: x = 9Increment: 1Number: 10

Page 4: Python Review.

IterationStartStopIncrementNumber

for x in range(0, 12, 2): print x

Start: x = 0Stop: x = 10Increment: 2Number: 6

range(0, 12, 2) [0, 2, 4, 6, 8, 10]

Page 5: Python Review.

IterationStartStopIncrementNumber

x = 0while x <= 10: print x x = x + 2

Start: x = 0Stop: x > 10Increment: 2Number: 6

Page 6: Python Review.

Iteration

x = 0while x <= 10: print x x = x + 2

x = 0while x <= 10: print x

x = 0while x <= 10: x = x + 2 print x

while x <= 10: x = 0 print x x = x + 2

Go Forever

2 4 6 8 10 12

All Zeros

Page 7: Python Review.

Color in Visualization

CMSC 120: Visualizing InformationLecture 4/24/08

Page 8: Python Review.

3 or more dimensions hard to visualize

Projection into lower-d space distorts data

Multifunctioning Graphical Elements

Multivariate Visualization

Page 9: Python Review.

ColorPre-attentive

1000s of different colors20-30 gray tonesPatterns, boundaries, movement

Page 10: Python Review.

Color PurposesEmphasisAppealDimensionality

Hello, here is some text. Can you read what it says?Hello, here is some text. Can you read what it says?Hello, here is some text. Can you read what it says?Hello, here is some text. Can you read what it says?Hello, here is some text. Can you read what it says?Hello, here is some text. Can you read what it says?

Shape of Nautilus Shell

Diameter in mm185 190 195 200 205 210 215 220

Wid

th in

mm

86

88

90

92

94

96

98

100

102

104

106FemaleMale

Page 11: Python Review.
Page 12: Python Review.

Color

Page 13: Python Review.

ColorThe quality of an object with respect to the light

reflected by the object

Determined visually by:• Hue: color• Saturation: purity• Brightness: % black

Page 14: Python Review.

Color

Page 15: Python Review.

Types of ColorsAdditive Colors

All visible colors are a sum of two or more

Primary ColorsRed, Green, Blue

SubtractiveComplementary ColorsRemoving an additive

color from white light

Page 16: Python Review.

Representing ColorEncoding

RGBCMKY = 1 - RGB

Page 17: Python Review.

Choosing the Right ColorHuman matches 16-20 colors

Addition of pattern elements

< 10 -12

> 20 can no longer be pre-attentively processed

VGA Monitor16 colors262,144 (643)

Super VGA256 colorsSeveral million

How much and which colors?

Page 18: Python Review.

Color Schemes

Page 19: Python Review.

Color SchemesColor may carry standardized meanings in

particular applications.

blue = water bodiesgreen = vegetationbrown = desert/mountainswhite = ice or snow, etc.

Color maps

Page 20: Python Review.

2004 Election

Page 22: Python Review.

Elevational map of KansasSimilar colors: subclassesDissimilar: barriers/unrelated

Page 23: Python Review.

Complementary ColorsOpposites on the color

wheel

High ContrastVibrant (full saturation)Can be jarring

Make something stand out

Bad for text

Page 24: Python Review.

Analogous ColorsAdjacent on Color Wheel

SereneComfortableFound in NaturePleasing

Contrast can be problematic

Use black, white, gray as an accent

Page 25: Python Review.

Analogous ColorsAdjacent on Color Wheel

SereneComfortableFound in NaturePleasing

Contrast can be problematic

Use black, white, gray as an accent

Page 26: Python Review.

Triadic ColorsEvenly spaced

Vibrant, even when pale hues are used

Balance color useOne dominateOthers accent

Page 27: Python Review.

Warm and CoolColorsCool colors

Short wave lengthviolet, blue, cyan, green large regionsfeatures for which no special

emphasis is desired

Hot colorsLong wavelengthyellow, orange, red, magenta

(long wavelength). Best used for small regions features for which special

emphasis is desired

Page 28: Python Review.

Hot and Cool ColorsColor Stereoscopic Effect

cool colors appear farther awayhot colors appear closer. enhanced by using black boundaries between color

areas, a small contour interval, and bright high-saturation or fluorescent