1/84
Looks like no tags are added yet.
Program
A file that usually contains one or more functions. Each function's definition starts with the "def" keyword
Function
a chunk of code (statements) that performs an action. Functions are given names and are reusable
Built-in Function
such as 'sqrt()' and 'int()'
User Defined Functions
functions that you create
Statment
a line of code which instructs Python to "do something". In JES, it is a line of code written either in the Command or Program areas. Normally have an expression inside them
Comment
one particular case where Python does NOT do something is called this. (side note for creator)
Expression
a piece of code (part of a statement) that can be evaluated to give a result.
Value
an expression which evaluates to itself. often called a 'constant'
Variable
just like in algebra, this is a name (in Python, often relevant 'words') that you can assign a value too, allowing you too reuse, for later use. Often also called a Lebel, identifier, or container
Operator
a mathematical symbol. This appears between two sub-expressions, and the combination of two sub-expression with the symbol forms a new larger expression
Type
the variables and expressions can be placed into different categories. This id often determines by the content in which it is used
Keyword
a word in Python that has already been given a meaning or purpose. Cannot be used as a variable name by you. ex; if, while, for, print, and
Assignment
the act of giving a value to a variable. One can imagine the "=" as a left arrow
Error
When your program has a problem
Arithmetic Processing
expressed using standard mathematical notation within the limitations imposed by a keyboard
Addition
+
Subtraction
-
division
/
%
modulo (remainder)
*
multiplication
**
exponentiation
String
anything in " " or ' '
s.count (substring)
returns number of occurrences of substring in "s"
s.find (textToSearchFor)
returns index or -1 if not found
s.rfind (textToSearchFor)
reverse fine, from end of string. Returns index or-1 if not found
Changing strings
remember that strings are immutable so to make a change "stick" you have to do, e.g. s=s.title()
list = s.split (characterToSplitOn)
Converting string to a list
s.join(list)
list to string. where e is the string to join the elements of list
Output
use 'print' to display stored values in the command or interactions are
requestNumber(message)
a dialogue box is opened, with the 'message' as a prompt for the user to enter a number
requestInteger(message)
a dialogue box is opened, with the 'message' as a prompt for the user to enter an integer
requestString(message)
a dialogue box is opened, with the 'message' as a prompt for the user to enter a string value
Relational Expressions
These look like standard arithmetic comparisons (but again with the limitations imposed by using a standard keyboard)
<
less than , eg. 5
less than or equal too
==
equal
!=
not equal
>=
greater than or equal
>
greater than
and
a and b, only true when a is true and b is true
or
a or b, is True when a is true, or when b is true, or when both a and b are true
not
not a, is true when a is false
if
use this to execute one clock of code or another, but not both
Range function
the built- in function created arithmetic lists, and is often used to produce the lists to drive for loops
for
use to execute a block of code known number of times
while
use to execute a code multiple times
while again
used to repeat a program
Lists
items separated by commas and placed inside square brackets [ ]
list1 + list2
concatenates the two lists
list [ i }
access element number i in list
len(list)
returns the number of elements in list
del list [ i ]
deletes element number i from list
list. append (value)
appends value from list
list. sort()
sorts the elects in list
list. reverse()
reverses the order of the elements in list
list.index(value)
returns the position of the first occurrence of value in list
list.insert (i, value)
inserts value into list at position i
list. count (value)
returns a count of the number of times value occurs in list
list.remove (value)
deletes the first occurrence of value in list
list.pop()
deletes and returns the last value in list
value in list
is true if value occurs in list and false otherwise
Text file processing
to read a file a line at a time
Function max()
takes any number of arguments and returns the largest value
Function min()
takes any number of arguments and returns to the smallest value
Computer Science
study of programs
Computer Scientists Study
how the programs are written, units used in the programs, what can programs be written for, how well the programs work with humans
Recipe
very similar to program
Algorithm
English, process description that is independent of any programming language
Ordered Steps
one after another (like following a recipe)
constants
may change the value (increase or decrease) depending on what is needed for the program
Key Concept
The computer does the work
Python
a language implemented in C
Jython
same language implemented in Java
Digitizing Media
encoding media into numbers, once converted, they can be used in a computer
Alan Perlis
Argued in 1961 that Computer Science should be apart of a liberal education: Everyone should learn to program
Programming
Exposes you to computational thinking
Floating Point
numbers with decimal points. also called real numbers or floats
Names
inside a function only have meaning while the function is being executed by the computer
File
Collection of bytes, with a name, that resides on some external medium like a hard disk
Directory
where the file is stored
base file name
the actual name of the file
file extension
indicates the type of file
Path delimiters
typically /\ to break up directory levels
JES
Jython Environment for Students: a simple editor in the program area
Names:
must start with a letter, no spaces, case sensitive, unique, don't use key words