Symbols

in if/else branches, 22 in index of string, 43 in while loops, 29 {} (curly brackets), creating hashes, 153 = (equal sign), assignment operator, 4, 35 == (equal sign, double), equal to operator, 4, 15

!= (exclamation point, equal sign), not equal to operator, 30

in format strings, 182 in function definition, 82 % (percentage symbol), preceding format strings, 180-182 . (period), in library function request, 69 + (plus sign), addition operator, 58 # (pound sign), preceding comments, 95, 205 > (right angle bracket), greater than operator, 62, 75 [] (square brackets)

creating arrays, 132, 134 enclosing index of array, 132 enclosing index of string, 42 enclosing key for hash, 153

append() method, arrays, 132, 144 arguments (parameters), 96-98, 101, 111 arrays (lists), 130-134, 144, 285 adding items to, 138 counting occurrences of values in, 138 creating, 132, 134 extending, 132, 138 index (offset value) for, 132 methods for, 138 multi-dimensional arrays, 152 removing items from, 138 reversing order of, 138, 140 searching, 138 sorting, 136-140, 144 askokcancel message boxes, 306 askquestion message boxes, 306 askretrycancel message boxes, 306 askyesnocancel message boxes, 304, 306 assignment of multiple values, 122-124 of single values, 4, 35 assignment operator (=), 4, 35 associative arrays. (see hashes) automated testing, 389

abstraction, 93 addition operator (+), 58 algorithms, 393

Bates, Bert (Head First Java), 388 Beighley, Lynn (Head First SQL), 170 bloated code, 81 books

Head First C# (Stellman, Greene), 388

Head FirstJava (Sierra, Bates), 388

Head First Object-Oriented Analysis & Design

(McLaughlin, Pollice, West), 392 Head First SQL (Beighley), 170 Learning Python, 4th Edition (Lutz), 386 brackets, curly ({}), creating hashes, 153, 175 brackets, square ([])

creating arrays, 132, 134 enclosing index of array, 132 enclosing index of string, 42 enclosing key for hash, 153 branches, 14, 15-21, 24 break statement, 255 Button() widget, 255

connecting code to, 239-244, 245 creating, 234-236

C# language compared to Python, 9 learning, 388 characters. (see strings) Checkbutton() widget, 331-335, 348 classes, 366, 372-373, 383. (see also methods; objects) constructors for, 370-373, 383 data for, 372 defining, 367-368 clock() function, time library, 70 close() method, files, 116, 144 code bloated, 81

command-line execution of, 391 comments in, 95, 205 debugging, 390 duplicating, 80-81 indents in, 21, 22 paths in, 13, 20-21 pseudo-code, 127 Python practices for, 386 reusing with functions, 81-82, 351-360 reusing with modules, 192-199, 200-202, 205-211, 214

running from IDLE, 7-8 saving, 7 testing, 389 white space in, 22 code examples. (see examples)

coffee examples. (see health club example; Starbuzz Coffee example)

collection variables. (see data structures) colon (:)

in if/else branches, 22 in index of string, 43 in while loops, 29 combo boxes, 248 command-line execution, 391 comments, 95, 205 conditionals, 35

in branches, 14-15 in while loops, 29 constructors (initializer methods), 370-373, 383 control variables, 278 controller, 277, 292 count() method, arrays, 138 crashes, 296

curly brackets ({}), creating hashes, 153, 175

data entry widgets

Checkbutton() widget, 331-335, 348 Entry() widget, 261-262, 266-267, 269, 292 model for, 276-278, 285, 292 OptionMenu() widget, 284-290, 292 populating dynamically, 288-290, 292 RadioButton() widget, 272-273, 275-280, 292 restricting input to, 271-273 Scale() widget, 336-338, 340-345, 348 Text() widget, 261, 263, 266-267, 269, 292 data storage, 129-130

data structures, 131, 150. (see also arrays; hashes) list of, 152

returning from functions, 164-167 database, 170-172, 175 datatypes, converting, 4, 9, 64-65, 75 date and time functions, 68-73 daylight() function, time library, 70 debugging, 390 decision points. (see branches) decode() method, 49 def keyword, 82, 111

delete() method, data entry widgets, 262, 263, 267, 269 delivery company example, 258-291 dynamic depot options for, 283-291 errors in delivery tracking, handling, 294-310 GUI for delivery system, 258-268 user input, controlling, 271-281 destroy() method, apps, 326, 348 dialog boxes, 248. (see also message boxes) dictionaries. (see hashes) directories, reading files in, 378-381 disk storage, 129

DJ example. (see mixing software example)

Don't Repeat Yourself (DRY), 88

DoubleVar() variable, 340, 345, 348

drop down lists, 248. (see also OptionMenu() widget)

DRY (Don't Repeat Yourself), 88

Eclipse IDE, 395 editors, 5, 395. (see also IDLE) Emacs editor, 395 encapsulation, 392 endswith() method, strings, 56 Entry() widget, 261, 269, 292 creating, 266-267 methods for, 262 equal sign (=), assignment operator, 4 equal sign, double (==), equal to operator, 4, 15 Eric IDE, 395

errors, 311. (see also debugging; testing) crashes resulting from, 296 displayed in Shell instead of GUI, 295 displaying in message boxes, 303-309 exceptions, 296-300, 311 TypeError message, 63-64 ValueError message, 119-120 event loop, 233-234, 255 events handlers for, 239, 244-245, 255 from operating system, 319, 348 from Window Manager, 319-324, 326-327 examples delivery company example, 258-291 game show example, 216-254

guessing game, 3-34 health club example, 178-213 mixing software example, 314-347, 350-382 Starbuzz Coffee, 38-74, 78-110 storeroom example, 294-310 Surf-A-Thon example, 114-143, 146-174 except statement, 298-300, 311 exceptions, 296-300, 311

exclamation point, equal sign (!=), not equal to operator, 30

extend() method, arrays, 138

false value, 14 File menu

New Window option, 6 Save option, 7

files handles for, 116 permissions for, 295 reading all files in directory, 378-381 reading from, 116-118, 166 find() method, strings, 56-58 float() function, 64-65, 118 for loop, 116-118, 154-156 format strings, 180-184, 186, 214 formatted data, 179

FQNs (fully qualified names), 207-211, 213, 214 Frame() widget, 364, 373, 383 fully qualified names (FQNs), 207-211, 213, 214 functional programming, 394

functions, 82. (see also reusing code; specific functions) calling, 82, 84

creating (defining), 82, 111

local functions, 356-358, 383

parameters for, 96-98, 101, 111

returning data structures from, 164-167, 170-172

returning values from, 87-88, 111

with same name in different modules, 206-211, 213

scope of variables in, 104-108

game show example, 216-254

answers, displaying in GUI, 246-254 answers, sound effects for, 216-228 answers, tallying, 216-218, 226-228 GUI for, 230-245 get() method data entry widgets, 262, 263, 269, 278 IntVar() variable, 332, 334 get_busy() method, channels, 221 global variables, 108-109, 244 gmtime() function, time library, 70 graphical user interface. (see GUI) greater than operator (>), 62, 75 Greene, Jennifer (Head First C#), 388 grouping widgets, 363-364 guessing game example, 3-34

guesses, determining if correct, 3-8 guesses, higher or lower hints for, 10-25 multiple guesses, allowing, 26-34

GUI (graphical user interface), 215, 230-232. (see also widgets)

displaying messages in, 246-254, 303-309, 311

errors not displayed in, 295

event loop for, 233-234

guidelines for, 341

positioning widgets in, 235-238

hash mark (#), preceding comments, 95, 205 hashes (dictionaries), 152, 175

adding data to, 153, 156, 161-162 creating, 153, 175 iterating through data, 154-156 keys of, restrictions on, 156 returning from functions, 164-167, 170-172 sorting, 158 Head First C# (Stellman, Greene), 388 Head First Java (Sierra, Bates), 388

Head First Object-Oriented Analysis & Design (McLaughlin, Pollice, West), 392

Head First SQL (Beighley), 170 health club example, 178-213 file format changes, 187-199 multiple price discounts, 204-213 price discount, 200-203 transactions, recording in file, 179-186 Help menu, 22 HTML, as strings, 49

IDE (Integrated Development Environment), 5, 9, 395 IDLE, 5, 9, 22

if/else branches, 4, 15-21, 24 import statement, 49, 69 importing libraries, 49, 69, 221, 226 modules, 193, 199, 202, 211, 214 indents in code, 21, 22

index (offset value) for arrays, 132 for strings, 42 index() method, arrays, 138 inheritance, 392

initializer methods (constructors), 370-373, 383 input() function, 4, 35, 387 insert() method arrays, 138

data entry widgets, 262, 263, 269 int() function, 4, 9, 35

Integrated Development Environment (IDE), 5, 9, 395

internationalization, format strings for, 186

interpreter, 5. (see also IDLE)

IntVar() variable, 249, 253, 255

iPython shell, 395

IronPython project, 388

items() method, hashes, 154, 175

iteration. (see loops)

Was this article helpful?

0 0

Post a comment