Created by jeriel.juarbe2031
over 9 years ago
|
||
A programmer can interact with python in 2 ways. what are they?
True or False
The first line in every Python script will indicate the path to the interpreter that should execute script
Print statements:
var1 = "jump off"
var2 = "the Bridge"
print var1,
print var2
raw_input() method:
used to retrieve info from STDIN
True or False
All data received from STDIN is stored as a string.
A programmer must convert the input to the intended data type.
What the four types of variables?
True or False:
placing a comma between variables creates a space between them
What are the 3 data type conversions
Helpful functions:
type(object)
exit(object)
help(object)
True or False
to handle exceptions a block of code is enclosed inside a try statement
# (-=) (*=) (/=)
(%=) only for INT
What exception is being described?
such as division by zero or a math result too large for the containing data type
What exception is being described?
second argument of division error or modulo operation is 0
What exception is being described?
when an input or output operation fails; opening a file that does not exists
What exception is being described?
an operation or function received the correct data type, but the value given was inappropriate; trying to convert a string to a number. if string contains anything other that numbers, this exception is raised
What are Lists?
This list method appends to the end of the list
This method removes an item from the position specified by index.
this method returns a sorted list without modifying the original list.
This method returns the NUMBER of elements in the lst
What are tuples?
What is a collection of characters, that are immutable and uses an index position to reference an element
We can change how strings are displayed using a fuck ton of methods.
True or False
This string method return copy of the string with each letter capatalized
This string method return copy of the string with each letter lower case
This string method returns the first index position where the substring is found. returns a -1 if the substring is not found
This method removes characters specified by substring. if substring not specified, white space is removed
This method returns a LIST of words in string using X as a delimiter. The delimiter cannot contain multiple values for the string to split upon.
string.join(x) method does what>
This method Returns the NUMBER of elements in a string
True or False
String Format Characters use a backslash \ also known as an escape character followed by another symbol
\n
or
\"
What are conversion specifiers?
start = %
Justification = minus (-) indicates value should be left justified
Precision = the dot (.) operator followed by an integer that specifies how many places of precision should be included
type of conversion for conversion specifiers:
d or i = signed integer decimal
f = floating point decimal
c = single ASCII char (int or char string)
s = string
% = Display a % sign
how do you concatenate 2 string variables?
If you need to modify a string you need to convert to a list then change the element of the list to a different value, and then convert back to a string
True or False:
Slice Notation is a powerful mechanism for extracting elements from a list or string.
object[start : stop : Step]