Python

Ace your homework & exams now with Quizwiz!

String Methods and the dot notation: find()-- know how and when to use these methods

..The method find() determines if string str occurs in string, or in a substring of string if starting index beg and ending index end are given.....

Modules: os

..The os module provides a big range of useful methods to manipulate files and directories.... http://www.tutorialspoint.com/python/os_file_methods.htm

Understand how to use nested quotes

nesting quotes allows a user to use one type of quote within a sting, i.e. """this is ''legal" ""

Understand the use of and difference between pickAFile() and makePicture.

pickAFile, picks a file, but does not allow the variable that catches it to maintain the information, makePicture has the variable properly reference the picture.

String Methods and the dot notation: lower()-- know how and when to use these methods

..The method islower() checks whether all the case-based characters (letters) of the string are lowercase... This method returns true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.

String Methods and the dot notation: upper()-- know how and when to use these methods

..The method isupper() checks whether all the case-based characters (letters) of the string are uppercase... This method returns true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.

String Methods and the dot notation: replace()-- know how and when to use these methods

..The method replace() returns a copy of the string in which the occurrences of old have been replaced with new, optionally restricting the number of replacements to max... This method returns a copy of the string with all occurrences of substring old replaced by new. If the optional argument max is given, only the first count occurrences are replaced.

String Methods and the dot notation: rfind()-- know how and when to use these methods

..The method rfind() returns the last index where the substring str is found, or -1 if no such index exists, optionally restricting the search to string[beg:end].... This method returns last index if found and -1 otherwise.

String Methods and the dot notation: startswith()-- know how and when to use these methods

..The method startswith() checks whether string starts with str, optionally restricting the matching with the given indices start and end.... This method returns true if found matching string otherwise false.

String Methods and the dot notation: swapcase()-- know how and when to use these methods

..The method swapcase() returns a copy of the string in which all the case-based characters have had their case swapped.... This method returns a copy of the string in which all the case-based characters have had their case swapped.

String Methods and the dot notation: title()-- know how and when to use these methods

..The method title() returns a copy of the string in which first characters of all the words are capitalized.... This method returns a copy of the string in which first characters of all the words are capitalized.

Lists Methods: split()

.The method split() returns a list of all the words in the string, using str as the separator (splits on all whitespace if left unspecified), optionally limiting the number of splits to num.... This method returns a list of lines.

strings

A type that represents sequences of characters.

float()

floating point number (decimal point allowed)

abs()

absolute value (not a decimal)

Understand the difference between ASCII code and Unicode

Unicode allows people to access more symbols in its system and allows users to write in more languages, ASCII covers basic latin letters and numbers

Know and be able to use each of the relational (comparison) operators.

+ adds two things together, as long as they are not strings and integers, if so they must be converted so that they both become strings, or integers. = means that a variable's value is the equivalence of anything on the right. == means that something must be equal to the thing on the right != means that something is not equal to the thing on the right * multiplies 2 things together, strings can be multiplied with integers in this case / divides 2 things, strings and integers cannot be divided unless they are converted > greater than < less than <= less than or equal to >= greater than or equal to

how lists are similar/different from strings

...Strings in Python are identified as a contiguous set of characters in between quotation marks. Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice operator ( [ ] and [ : ] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end. Lists are the most versatile of Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in C. One difference between them is that all the items belonging to a list can be of different data type.

Understand how to use for loops with strings

..The for loop in Python has the ability to iterate over the items of any sequence, such as a list or a string.... If a sequence contains an expression list, it is evaluated first. Then, the first item in the sequence is assigned to the iterating variable iterating_var. Next, the statements block is executed. Each item in the list is assigned to iterating_var, and the statements(s) block is executed until the entire sequence is exhausted. http://www.tutorialspoint.com/images/python_for_loop.jpg

String Methods and the dot notation: capitalize()-- know how and when to use these methods

..The method capitalize() returns a copy of the string with only its first character capitalized. For 8-bit strings, this method is locale-dependent.... This method returns a copy of the string with only its first character capitalized.

String Methods and the dot notation: endswith()-- know how and when to use these methods

..The method endswith() returns True if the string ends with the specified suffix, otherwise return False optionally restricting the matching with the given indices start and end.... This method returns True if the string ends with the specified suffix, otherwise return False.

String Methods and the dot notation: isalpha()-- know how and when to use these methods

..The method isalpha() checks whether the string consists of alphabetic characters only.... This method returns true if all characters in the string are alphabetic and there is at least one character, false otherwise.

String Methods and the dot notation: isdigit()-- know how and when to use these methods

..The method isdigit() checks whether the string consists of digits only..... This method returns true if all characters in the string are digits and there is at least one character, false otherwise.

file and directory structures

files have a name, they can be found by going through the computers directory

algorithm,

A general process for solvig a category of problems.

What are modules and why are the useful?

A module is a Python object with arbitrarily named attributes that you can bind and reference. A module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand and use. Simply, a module is a file consisting of Python code. A module can define functions, classes, and variables. A module can also include runnable code.

what a list is?

A sequence of values, represented in Python using square brackets

program,

A set of instructions that specifies a computations.

floating-point numbers,

A type that represents numbers with fractional parts.

integers,

A type that represents sequences of characters.

Use for loops to repeatedly execute a block of code.

for loops runs a loop of all objects within the range of a list, for example: for p in range(picture): p is shown as the object that the for loop will look for in picture and edit it with the items in the for loop

range()

gives sequence a range from where to begin and where to stop

cos()

gives the cosine of the number in its parentheses

List Functions: max()

gives the maximum value of an element within a list

List Functions: min()

gives the minimum value of an element within a list

sin()

gives the sine of the number in its parentheses

Know how to use if, else, elif to conditionally execute a block of code.

an if statement asks a question to the computer, which looks to see if the variables that the programer placed in the system exists, if it is true the computer will execute anything indented within the if statement, an elif asks another question to the computer in case the first question is proven untrue, if the elif is proven to be true, then the computer will execute anything indented under the elif statement. an else statement is activated when the if and elif statement are proven false.

Use def to define a function.

in order to define a function the keyword "def" is used as the first word prior to the designated for example: def myFunction():

Know and be able to use the logical operators and, or, not to formulate compound conditions

and and or in an if or elif statement will change the expectations of the question, when using "and" the logical operation will look for both statements to be true in order for it to complete its operation. an "or" will will have the if or elif statement check to see if one of the statements it was given is true in order for it to complete its objective

Modules: math

math model hold lots of important mathematical functions like sine, and square roots

why comments are an important part of a program

comments allow an external person, or another programer, the ability to understand what the program is doing, and allows the other programmer to edit the program properly

Know how to perform certain picture effects, such as Chromakey, Sepia, Negative, or Greyscale.

negative effects in color requires that the current colors of red green and blue, are subtracted from their pure counterpart, such as pure red, pure blue, and pure green grayscaling a picture requires the addition of all the colors within the pixels, and divide that amount by 3 sepia requires that all the colors within the for loop, and if statement are met properly edited then they are able to look proper

Distinguish between Python and JES.

python is a computer language that is embedded in C, while JES is an application that allows a user to write in jython, which is a variation of python that is embedded in java

bug

An error in a program.

Files functions and methods: write()

writes within a file(note: if the file that you are writing in has the same directory and name as another file, it will overwrite it)

how to use the modules

you would have to import the modules into JES, which should be the first thing on the command line

Modules: datetime

datetime module supplies classes for manipulating dates and times

max()

delivers the maximum value of a list

min()

delivers the minimum value of a list

Files functions and methods: open()

The open() function opens and returns a file handle that can be used to read or write a file in the usual way.

digitization.

The process of encoding media into little bits that os also call going digital

debugging

The process of finding and removing any of the three kinds of programming errors.

Modules: sys

This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter

Know how to call functions with arguments and return values from functions.

In order to call a function with arguments in order to have it return is byproduct, you load the program into the JES, and type in the command line the programs name, as well as the argument that fills the space of the parameter,

Understand the difference between parameters and arguments

Paramaters are place holders, they hold a space in a function in which an argument can be placed and the program can function with their placed arguments

Understand how to use triple quotes

Python's triple quotes comes to the rescue by allowing strings to span multiple lines, including verbatim NEWLINEs, TABs, and any other special characters.

What does it mean to have a string in raw mode?

Raw strings don't treat the backslash as a special character at all. Every character you put into a raw string stays the way you wrote it:

Understand how to use double quotes

Strings are amongst the most popular types in Python. We can create them simply by enclosing characters in quotes. Python treats single quotes the same as double quotes.

Understand how to use single quotes

Strings are amongst the most popular types in Python. We can create them simply by enclosing characters in quotes. Python treats single quotes the same as double quotes.

def,

The 'def' keyword is used to create a new user defined function. def newFunction():

elif,

The 'elif' keyword stands for 'else if'. In a boolean control structure, 'elif' defines that if the first test evaluates to False, we continue with the next one. If none of the tests is True, the else statement is executed. name = "Luke" if name == "Jack": print "Hello Jack!" elif name == "John": print "Hello John!" else: print "Hello there!"

else,

The 'else' keyword is optionally used in an if-statement. The statement after the 'else' keyword is executed, unless the condition prefaced by 'if' is True. age = 17 if age > 18: print "Driving licence issued" else: print "Driving licence not permitted"

for,

The 'for' keyword is used to iterate over items of a collection in order that they appear in the container. i = [1, 2, 3] for x in i: print x

if,

The 'if' keyword is used in a control statement to determine which statements are going to be executed. age = 17 if age > 18: print "Driving licence issued" else: print "Driving licence not permitted"

in,

The 'in' keyword points a test from an expression to an object. print 4 in (2, 3, 5, 6) >> False print 4 in (2, 3, 4, 5) >> True The 'in' keyword tests if the number four is in the tuple. The second usage is traversing a tuple in a 'for' loop.

while

The 'while' keyword is a basic keyword for controlling the flow of the program. The statements inside the while loop are executed, until the expression evaluates to False.

Know what escape sequences or backslash escapes are and how to use them (e.g \n \b \t \uxxxx

\n creates a new line in the string. \b creates a backspace in the string. \t creates a tab in a string \uXXXX where XXXX is a code made up of 0-9 and A-F represents the unicode character with that code

understand the term matrix

a 2 dimensional array (e.g. pictures )

Understand and know how to use nested for loops

a nested "for" loop has one loop that has another loop indented within it, the loops must now complete completing their task in every variable that is in both loops

understand the term pixel

a picture element, used to create a picture

how a picture is encoded.

a picture is encoded into a a computer by scanning it and translating the information into electrical pulses which translate into a language that the computer will understand, the language will then translate into an array of pixels, a picture element

understand the term array

a sequence of the same type

Manipulating strings: Know how to use the subscript operator ([]) to reference a string or part of the string, and how to use the + operator to concatenate strings.

a subscript operator allows the user to choose what elements inside a list he wants the function to utilize it starts the list at 0 and builds from there, it needs at least 1 or 2 parameters in order to function properly, i.e. list = [1,2,3,4,5] print (list[1:4]) (will look for all elements between the index of 1)

Files functions and methods: close()

closes a file

Demonstrate understanding of picture and RGB color encoding in JES.

color is found in a computer through the RGB color model, which is given a specific number amount for each color

Modules: random

random: an import in JES that allows a computer to create a function that derives its answer from a random sequence

ord()

returns an integer of the string entered in its parenthesis

Know how to represent text.

text in a computer is written as unicode, which is then translated into a text format that the user can understand

Explain JES command area and editor.

the command line in JES allow the programmer to write single line commands to JES immediately and get its results, while the editor wind allows the programer to create a program that can do a specific task

Understand sequential execution of lines of code in blocks.

the computer runs through the code in a similar manner that we read books, if a line of code is out of sequence, the program will either enter a logical error, in which the program runs, but not perfectly, or it performs a syntax error, in which the computer does not perform a program due to a variable that was misplaced with the out of sequence code

Know how to use the len() function to get the number of characters in a string

the len() function allows a programmer to count how many characters there are in a string or elements in a list and returns a numeric value....

Trace, explain, correct or write short functions to do pixel-by-pixel picture manipulations(e.g. negative, lighten, darken, color tinting, grayscale, sepia toning, posterizing)

to darken a pixel, a multiple amount of pixels, a for loop is needed to make sure that all pixels that are within the range of the picture are affected by the change in color. in the case of a creating certain effects in a pixel, adding, subtracting, multiplying, or dividing the color of all the pixels needed to be changed, or for some effects, such as lightening or darkening, a a pixel can be added to their smaller functions that will cause the color of the pixel to change i.e. color = darken(p), setColor(p, color)

encoding,

turning information into electrical signals for a computer to decipher them and read the information

str()

turns an object into a string

int()

turns an object into an integer

Understand and know how to use the while loop

unlike a for loop, which goes through all the variables within its given range and stops, a while loop

how to read from a text file

use the method read()

how to write to a text file

use the method write()

Know how to use nested for loops as well as getPixels() and which would be better for certain manipulations. For example: Which would you use to copy part of a picture? Which would you use to reduce red in an entire picture?

using a for loop allows the computer to gain see all of a certain variable, getPixels() allows the computer make a connection between a user-given variable, and the pixels within the picture so it has all the pixels in a picture reference the variable

Apply naming rules in Python to name variables or functions.

variables cannot be numbers, they cannot start with a number, nor can they have any special characters in front or in the variable name; such as :! @ # &. It is also important to know that special characters cannot be variables as well,

Call (invoke) functions from inside other functions.

when calling a function from within a function, a variable must be made so that when the function is called, it can be received and used.

Explain what it means to pass an argument into a function.

when you evaluate the function by specifying its name with an input value (an argument) in side a parenthesis

know what would be returned if you put them in an if statement.

when you put something in an if statement, you have to see what is being returned to the user about the if statement

Lists Methods: append(),

will add an element to the back of the list

Lists Methods: count()

will count all elements in a list and return the total amount

Files functions and methods: readline()

will read from a file to create a multiline list

Files functions and methods: read(),

will read from a file to create a one line list

Lists Methods: remove()

will remove an element from the list

Lists Methods: reverse()

will reverse the order of a list

Lists Methods: sort()

will sort the elements of the list in alphabetical, or numerical order,


Related study sets

Chapter 44: Assessment and Management of Patients With Biliary Disorders

View Set

EMT AAOS Chapter 11 Pharmacology

View Set

ATI Mental Health Practice 2016 A

View Set

Database Concepts & Administration Exam 2

View Set

What is your name? 你叫什么名字?

View Set

4/20 All section Questions, ****

View Set

Tissue integrity/infection/vaccines

View Set