Karteikarten
Python Programming Language (Day 1)
Karten in diesem Stapel (37)
- 1A programmer can interact with python in 2 ways. what are they?1) one line at a time through Python Interpreter
2) by saving the source code to a file and instruction Python to process it - 2True or False The first line in every Python script will indicate the path to the interpreter that should execute scriptTRUE
- 3Print statements: var1 = "jump off" var2 = "the Bridge" print var1, print var2jump off the Bridge
- 4raw_input() method: used to retrieve info from STDINFYI
- 5True or False All data received from STDIN is stored as a string. A programmer must convert the input to the intended data type.TRUE
- 6What the four types of variables?string
Integer
Float
Boolean - 7True or False: placing a comma between variables creates a space between themTRUE
- 8What are the 3 data type conversionsstr(object)
int(object)
float(object)
example:
airspeed=int(raw_input("what is..."))
or
value = "15"
value = int(value) - 9Helpful functions: type(object) exit(object) help(object)query an object about what it can do
- 10True or False to handle exceptions a block of code is enclosed inside a try statementTrue
- 11# (-=) (*=) (/=) (%=) only for INTTrue
- 12What exception is being described? such as division by zero or a math result too large for the containing data typeArithmeticError
- 13What exception is being described? second argument of division error or modulo operation is 0ZeroDivsionError
- 14What exception is being described? when an input or output operation fails; opening a file that does not existsIOerror
- 15What 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 raisedValueError
- 16What are Lists?groups data (like an Array)
can be comprised of mixed data types and can grow and shrink in size if necessary - 17This list method appends to the end of the listlist.append(object)
- 18This method removes an item from the position specified by index.list.pop()
- 19this method returns a sorted list without modifying the original list.sorted()
- 20This method returns the NUMBER of elements in the lstlen()
- 21What are tuples?similar to list except that once created it is immutable (cannot be modified).
if data inside requires change , slice notation can be used to extract elements of the tuple - 22What is a collection of characters, that are immutable and uses an index position to reference an elementStrings
- 23We can change how strings are displayed using a fuck ton of methods. True or FalseTrue
- 24This string method return copy of the string with each letter capatalizedstring.upper()
- 25This string method return copy of the string with each letter lower casestring.lower()
- 26This string method returns the first index position where the substring is found. returns a -1 if the substring is not foundstring.find(subscript)
- 27This method removes characters specified by substring. if substring not specified, white space is removedstring.strip(subscript)
- 28This 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.split(x)
- 29string.join(x) method does what>returns a string made up of the concatenation of all data found in x. Useful when converting lists to strings (needs a string)
- 30This method Returns the NUMBER of elements in a stringlen(string)
- 31True or False String Format Characters use a backslash \ also known as an escape character followed by another symbol \n or \"True
- 32What are conversion specifiers?used as placeholders for values to be inserted into a string
- 33start = % 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 includedconversion specifiers info
- 34type 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 % signtypes
- 35how do you concatenate 2 string variables?string3= string1 + string2
- 36If 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 stringFucking retarted
- 37True or False: Slice Notation is a powerful mechanism for extracting elements from a list or string. object[start : stop : Step]True
Informationen
- Beschreibung
- Karteikarten am Python Programming Language (Day 1), erstellt von jeriel.juarbe2031 am 26/08/2014.
- Erstellt von
- jeriel.juarbe2031
- Aufrufe
- 284
- Bewertung