Quiz
Midterm cs8
Dieses Quiz enthält Fragetypen, die sich im gewohnten Player öffnen.
Fragen in diesem Quiz (33)
1
[blank_start]Information[blank_end] – structured, meaningful facts
Word document (.docx)
[blank_start]Data[blank_end] – raw information that must be processed to be useful
Keyboard input
[blank_start]Program[blank_end] – a [blank_start]program[blank_end] is set of computer instructions and related information used for solving a problem- AData
- BInformation
- CProgram
- Dprogram
2[blank_start]Exceptions[blank_end] are errors detected during program execution
- AExceptions
3[blank_start]Syntax Errors[blank_end] – errors detected when attempting to parse a program (when the interpreter is converting code to instructions)
- ASyntax Errors
4leaving a logical operation as soon as the result is guaranteed
- AShort Circuiting
- BComparison operators
5types that store multiple data elements
- Asequences
- Blines
- Cfunctions
- Dkeywords
6In dictionaries
A key is an immutable value used to identify a specific value in a map- ARichtig
- BFalsch
7• ‘[blank_start]and[blank_end]’ is decided when the left side evaluates to False ( ‘False and X’ is never True)
• ‘[blank_start]or[blank_end]’ is decided when the left side evaluates to True ( ‘True and X’ is always True)- Aand
- Bor
8• [blank_start]Files[blank_end] is a named collection of information
- AFile
9• There are three ways to access a file
• [blank_start]Read mode[blank_end] – just looking at a file (any number of programs can read data from different parts of the file at the same time)
• [blank_start]Write mode[blank_end] – change data in the file (only one program can makes changes at any given time)
• [blank_start]Append mode[blank_end] – append data to the end of the file (only one program can append at a time)- ARead mode
- BWrite mode
- CAppend mode
10• The [blank_start]open()[blank_end] function attempts to open a file and return a [blank_start]file objec[blank_end]
- Aopen()
- Bfile object
11a set of data and associated functions which represent something (similar to how a string works – it stores data and has methods to operate on it)
- Aobject
- Bfile
- Cfunction
- Dclass
- Eloop
12• The [blank_start]write()[blank_end] function writes a string to a file
- Awrite()
13• seek( distance, from)
• [blank_start]distance[blank_end] – the number of bytes to move (can be negative to move backwards)
• [blank_start]from[blank_end] – the staring location
[blank_start]0[blank_end] – the beginning of the file
[blank_start]1[blank_end] – the current position
[blank_start]2[blank_end] the end of the file- Adistance
- Bfrom
- C0
- D1
- E2
14• [blank_start]strip( chars )[blank_end] – a string function which removes the characters specified by ‘chars’ from the beginning and end of the string. If no parameter is provided whitespace is removed (spaces, tabs, newlines, etc.)
• [blank_start]lstrip( chars )[blank_end] – same as strip, but only removes characters from the beginning of the string
• [blank_start]rstrip( chars )[blank_end] – same as strip, but only removes characters from the end of the string- Astrip (chars)
- Blstrip (chars)
- Crstrip (chars)
15• The os module contains many functions
• We are interested in two specific functions
• [blank_start]os.remove[blank_end]( filename ) – removes a file with name ‘filename’
[blank_start]os.rename[blank_end]( old_filename, new_filename ) – renames a file with name ‘old_filename’ with the name ‘new_filename’- Aos.remove
- Bos.rename
16collections of Python definitions and statements, similar to a script
- Amodules
- Bscripts
- Cfunctions
- Dclasses
- Eobjects
17• There are two ways to import modules
1. [blank_start]import module_name[blank_end]
2. [blank_start]from[blank_end] module_name [blank_start]import[blank_end] function_name
• Both methods will make modules available, but accessing the modules will be different depending on which method is used
• Method 1 requires the [blank_start]module name be used each time[blank_end]
import random
random.randint()
• Method 2 allows the module name to be omitted, but will overwrite any [blank_start]other functions with the same name[blank_end]
from random import randint
randint()- Aimport module_name
- Bfrom
- Cimport
- Dmodule name be used each time
- Eother functions with the same name
18• __name__ variable will be ‘[blank_start]__main__[blank_end]’ if a script is run as the main program, otherwise it will contain the module name if the file is used as a module
- A__main__
19• [blank_start]Attributes[blank_end] are [blank_start]features of objects[blank_end] which can be represented as information. For example, a name is an attribute of a person (all things that are people have a name)
• [blank_start]Methods[blank_end] are [blank_start]the functions[blank_end] that belong to an object. These generally change the information stored about the object. For example, “breathing” could be a function of a person (which would update the blood-oxygen value, perhaps)- AAttributes
- BMethods
- Cfeatures of objects
- Dthe functions
20• [blank_start]Objects[blank_end] allow programmers to define specific sets of data and functions which are used to represent real world objects
• A [blank_start]class[blank_end] is a named definition of an object which details the variables and functions associated with it – a class is like a blueprint
• An [blank_start]instance[blank_end] is a copy of a class which has data values – an instance is like a specific house built from a blueprint- AObjects
- Bclass
- Cinstance
21• Use the ‘[blank_start]class[blank_end]’ keyword to declare a class
- Aclass
22• All functions inside a class take a [blank_start]parameter[blank_end] (generally named ‘[blank_start]self[blank_end]’) which will always be the copy of the class on which the function is being called
- Aparameter
- Bself
23class Cow:
name = ‘Betsy’
def print_name( [blank_start]self[blank_end] ):
print( [blank_start]self[blank_end].name )
return- Aself
- Bself
24Creating an Instance
[blank_start]class[blank_end] Cow:
name = ‘Betsy’
def print_name( self ):
print( self.name )
return
[blank_start]my_pet = Cow()[blank_end]
my_pet.print_name()- Aclass
- Bmy_pet = Cow()
25• [blank_start]Variables[blank_end] inside an instance of a class are called [blank_start]instance variables[blank_end] – they are accessed through the ‘self’ parameter passed to functions
• [blank_start]Instances[blank_end] are created by writing the class name followed by parenthesis – this calls a function named [blank_start]__init__( self, … )[blank_end] which is always called when a new copy of the class is created
• __init__() is called the [blank_start]constructor function[blank_end]- AVariables
- Binstance variables
- CInstances
- D__init__( self, … )
- Econstructor function
26• A [blank_start]class[blank_end] is a blueprint for building objects
- Aclass
27• Remember that functions can be called on an object as follows:
my_car = Car( “Ford” )
[blank_start]my_car.printModel()[blank_end] # prints ‘Ford’
• But functions are defined for classes, which is why the ‘self’ variable is used. So we can also access them with another notation:
[blank_start]Car.printModel( my_car )[blank_end]- Amy_car.printModel()
- BCar.printModel( my_car )
28• Subclasses can [blank_start]derive[blank_end] from, or [blank_start]extend[blank_end] a base class
- Aderive
- Bextend
29• When a class derives from a base class it has all the features of the base class and can add more
class [blank_start]Animal[blank_end]:
# Has a name
class Pet( [blank_start]Animal[blank_end] ):
# Has a name, may also have vaccines- AAnimal
- BAnimal
30• The [blank_start]base class[blank_end] is the generic class which will be “imported”
• The [blank_start]derived class[blank_end] is a class which imports another class and provides additional functionality
class derived_class( base_class ):
# …
class derived_class( base_class1, base_class2, … ):
# …- Abase class
- Bderived class
31an area in which variable names are grouped (which is important for uniqueness)
- Anamespace
- Bfunction
- Ccomment
- Dloop
32• A [blank_start]record[blank_end] is a structured collection of information describing a particular piece of information in a program
• Records have [blank_start]attributes[blank_end] – named pieces of data
• Example: a banking application
• Each customer has an ID, a checking account #, a checking account balance, a savings account #, and a savings account balance- Arecord
- Battributes
33Column Delimited Format
• Very [blank_start]old format[blank_end] – used infrequently today
• Primarily found in use by [blank_start]legacy[blank_end] systems
• Records are a [blank_start]fixed[blank_end] size – each attribute gets a fixed amount of space- Aold format
- Blegacy
- Cfixed
Informationen
- Beschreibung
- Quiz am Midterm cs8, erstellt von Ержан Шынгаев am 28/10/2015.
- Autor
- Ержан Шынгаев
- Sprache
- English
- Aufrufe
- 0
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz