Section 1

Preview this deck

Paragraphs

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

4 years ago

Date created

Mar 14, 2020

Cards (39)

Section 1

(39 cards)

Paragraphs

Front

Multiple lines or blocks of code

Back

Sentence

Front

Single line of code

Back

Syntax

Front

The grammar, structure, or order of the elements in a language statement.

Back

Three types of steps in a script/program

Front

Sequential - one after another Repeated - step done multiple times Conditional - performs one of several different steps based on a condition

Back

Symantic error

Front

Python statements are written correctly, but script and/or program does not perform the task intended

Back

Program

Front

Script or set of instructions that tell CPU what to do Stored instructions for CPU to follow

Back

Script

Front

Enter a sequence of statements (lines) into a file using a text editor Tell python to execute

Back

Guardian pattern

Front

Guard against division by 0 error by using and >>> x = 6 >>> y = 0 >>> x >= 2 and y != 0 and (x/y) > 2 False -- the y!=0 statement guards against division by zero

Back

Output devices

Front

Means by which CPU provides information back to user Monitor, printer, speakers

Back

In Python 2, integer division

Front

Truncates (drops resulting fraction of division) 3/2 = 1 (the 0.5 gets dropped)

Back

Compound statement

Front

A statement that consists of a header and a body. The header ends with a colon (:). The body is indented relative to the header. if / else -- if / elif / else -- try / except

Back

Secondary memory

Front

Where information is stored Slower than main memory Memory is retained after shut down or reboot Hard drive, jump stick, cd

Back

Two way decisions (if / else)

Front

if x<10: print 'x is less than 10' else: print 'x is equal to or greater than 10'

Back

Branch

Front

One of the alternative sequences of statements in a conditional statement

Back

Constants

Front

Numbers, letters or strings that do not change

Back

Multi-way decisions (if / elif / else)

Front

x=int(15) if x <10: print "x is less than 10" elif x>10 and <50: print "x is greater than 10 but less than 50" else: print "x is greater than 50"

Back

Variable names

Front

Must begin with a letter or an underscore "_" Can contain no spaces Cannot be a Python keyword

Back

Nested conditional

Front

A conditional statement that appears in one of the branches of another conditional statement

Back

Concatenation

Front

Joining together (of strings) X='Jerry ' Y='is old' Print X + Y >>> Jerry is old

Back

try and except

Front

When you know a sequence of instructions may encounter a problem Statements to be added if an error occurs --------------------------------------------------------------- astr=raw_input('Enter a number: ') try: istr=int(astr) #convert to integer? except: istr=Non-numerical input received print istr

Back

Traceback

Front

A list of the functions that are executing, printed when an exception occurs

Back

Syntax error

Front

Mistake made in grammar while writing Python statement

Back

Interactive

Front

Method of using Python, typing code in one line at a time (at the Python prompt >>>)

Back

Logic error

Front

Error in the way python statement was written Usually related to the order of the words or characters used in the statement

Back

Guardian pattern

Front

Where we construct a logical expression with additional comparisons to take advantage of the short-circuit behavior. Left to right evaluation of statement involving logical operators (and / or / not)

Back

RAM

Front

Random Access Memory Main memory - were info is store that CPU needs very quickly Fast, small, temporary storage Lost on shutdown or reboot

Back

Comments

Front

Everything to the right of # on a specific line is ignored by python compiler and is considered a comment Multi line comments can be entered with ''' Comment line 1 Comment line 2 '''

Back

Operator precedence rules

Front

Parenthesis Exponentation Multiplication, division, remainder Addition and subtraction Flow from left to right

Back

if

Front

If x<10: Print 'Less than 10' If x >=10: Print 'Equal to or greater than 10'

Back

Short circuit

Front

When Python is part-way through evaluating a logical expression and stops evaluation because the final value for the expression is known without needing to evaluate the rest of the expression. Left to right evaluation of statement involving logical operators (and / or / not)

Back

Input devices

Front

Means by which to receive input from user Keyboard, mouse, microphone

Back

CPU

Front

Central processing unit Executes instructions Runs the program very fast

Back

Python file extension

Front

***.py

Back

Assignment statement

Front

Assigns a value to a chosen variable

Back

Boolean expression

Front

Expression that is either true or false

Back

type

Front

e = hello >>>type (e) Must put the variable in ( ) <type 'str'> type of e is a string

Back

Many elifs are permitted

Front

x=45 if x<=5: print "x is less than or equal to 5" elif x<=10: print "x is greater than 5 but = to or less than 10" elif x<=25: print "x is greater than 10 but = to or less than 25" elif x>25: print "x is greater than 25"

Back

Comparison operators

Front

Less than ( < ) x < y Less than or equal ( <= ) x <= y Greater than ( > ) x > y Greater than or equal ( >= ) x >= y Equality ( == ) x == y Inequality ( != ) x != y

Back

Chained conditional

Front

A conditional statement with a series of alternative branches

Back