Python Final Exam, Python- Midterm 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

how do you access an element of a string?

index of the element surrounded by square brackets example: hello_str= 'example' print(hello_str[1]) prints e

what is a computer?

a digital electronic machine that can be programmed to carry out sequences of arithmetic or logical operations automatically

what is a breakpoint?

a line number of interest in your program when the debugger is running, it halts execution of the program at this line

what is the definition of an index?

a location in the sequence of a particular element; positive values count up from the left beginning with index 0 and negative values count down from the right beginning with -1

what does it mean that a sequence is iterable?

a loop can iterate through each element of a sequence in order, meaning it moves character by character

what is a variable?

a name we designate to represent an object in our program

what is deep copy?

a new object and recursively adds the copies of nested objects present in the original elements

what is shallow copy?

a new object is created which store the top level reference of the original element

what is an algorithm?

a process or set of rules to be followed in calculations or other problem-solving operations

what is a string function?

a program that performs some operation takes an argument and returns a value based on the argument and the function's operation

what is a string?

a sequence of characters indicated by quotation marks; the exact sequence of characters is maintained

what is a program?

a sequence of instructions

what is a program?

a sequence of instructions that are converted into binary commands for the processor to understand

what is a method?

a sequence of steps that describes how to solve a problem

what is a string method?

a variation on a function that is applied in the context of a particular object indicated by dot notation invocation ex: my_str.upper( ) = upper case string

what is slicing?

ability to select a subsequence of the overall sequence

what does insert( ) do?

adds the new element specific value in the specific position

what does append( ) do?

adds the new element to the end of the list

what are pre-code planning tools?

algorithms flowcharts pseudocode

what is a binary file?

all the information is taken directly without translation, not readable

what is a selection statement?

allows a program to test several conditions and execute instructions based on which condition is true

what does 'continue' mean for debugging?

an action to take in the debugger that will continue execution until the next breakpoint is reached or the program exits

what does 'stepover' mean for debugging?

an action to take in the debugger that will step over a given line if the line contains a function, the function will be executed and the result returned without debugging each line

what is an exception?

an event that occurs during the execution of a program that disrupts the normal flow of the program's instructions in general, when script encounters a situation that it cannot cope with represents an error

what does it mean for an operation to be overloaded?

an operation can perform multiple things depending on what type of element is working with the operator + is overloaded because it can concatenate or add depending on if there's integers or strings

what does the 'in' operator do?

checks to see if a substring exists within a string if it doesn't exist: returns false if it does exist: returns true my_str = 'abc' 'a' in my_str returns true

what is 'w' mode?

clears the file's contents and is write-only creates and opens a new file if the file doesn't exist

what is 'w+'?

clears the file's contents and writes at the beginning of the file creates and opens a new file if one doesn't exist

what should you always do at then end of using a file?

close it using file.close( ) flushes the buffer contents from the computer to the file and tears down the connection to the file

what is a high-level language?

close to human language, like in Python compiler can work through your code line-by-line

what are the requirements for concatenation and repetition?

concatenation requires two strings repetition requires a string and an integer

what is a file stream?

contains a buffer of the information from the file, and provides information to the program connects the file information on disk to the program

what does the 'try' suite do?

contains code that we want to monitor for errors during its execution if an error occurs anywhere in the suite, Python looks for a handler that can deal with the error, otherwise the program halts and error message is shown

what is a cache?

copy of information from the file that is stored

what is a buffer?

data area shared by hardware devices or program processes that operate at different speeds or with different sets of priorities allows each device or process to operate without being held up by the other

what does the diamond shape in a flowchart represent?

decision

what is a data type?

defines a collection of data values and a set of predefined operations on those values

what are the aspects of an algorithm?

detailed effective specific behavior general purpose

how is a string mapped?

each character is associated with an integer, such as UTF-8. function ord( ) takes a character and returns its UTF-8 integer value then the function chr( ) takes an integer and returns the UTF-8 character

what are the strategies for program design/problem solving?

engage/commit visualize/see try it/experiment simplify analyze/think relax

what does accessing a file mean?

establishing a connection between the file and the program and moving data between the two

what is computer software?

executable programs: word processor, spread sheet, internet browser, etc

all the elements in a list should be of the same data type?

false

what is pseudocode?

false code used to describe how a computer or an algorithm works acts as an intermittent step before developing actual code

what is the CPU cycle?

fetch instruction decode instruction execute operation store result repeat

example of an exception?

indexing past the value of a list, value not found, file not closed, etc

what is a overflow error?

indicates an arithmetic operation has exceeded the limits of the current python runtime typically due to excessive float values

what is a zerodivision error?

indicates the second argument used in a division or modulus operation was zero

what are the components of a computer system

input devices- mouse, keyboard, joystick, microphone output devices- monitor, printer central processing unit- brain of the computer main memory- RAM (volatile and temporary) secondary storage of memory (nonvolatile and permanent)- hard drives, floppy disc, USB network- bluetooth, wifi

what does a parallelogram represent in a flowchart?

input/output

what is 'a' mode?

file's contents are left intact and new data is appended at file's end creates and opens a new file if file doesn't exist

what is 'a+'?

file's contents are left intact and read/write at file's end creates and opens a new file if one doesn't exist

what is a text file?

files where control characters such as "/n" are translated; generally human readable

what is a run-time error?

happens when Python understands what you're saying, but is unable to follow your instructions

what is a key error?

happens whenever a dict() object is requested and the key is not in the dictionary

what is a relational expression?

has two operands and one relational operator operator- compares the value of its two operands

what is selection?

how programs make choices, and it is the process of making choices that provides a lot of the power of computing

what are the defaults of slicing?

if either start or finish are not provided, it defaults to the beginning of the sequence for start and the end of the sequence for finish step size is 1

what is an import error?

raised when you try to import a module that doesn't exist may happen if you make a mistake typing in a name

what are the aspects of a program?

readability robustness/reliability correctness

what is 'r+' mode?

reads and overwrites from the file's beginning gives an error if file doesn't exist

what does the line represent in a flowchart?

relationship between shapes

what does pop( ) do?

removes the element whose index is specified by default removes the last item

what does sort( ) do?

sorts the elements of same data type can be ascending or descending order

what does an oval represent in a flowchart?

start/end

what is an iterative statement?

statement that causes a statement or collection of statements to be execute zero, one, or more times

what does the 'len' function do?

takes an argument as a string and returns an integer length of the string len(my_str) = some integer

what is "end of line" character?

terminates each line of text in a text file /n by default

what are the two types of files?

text files and binary files

what is a value error?

there's a problem with the content of the object you tried to assign value to

are strings immutable or mutable?

they're immutable so you can't change them once you make them they can be used to make another new string though

what is half open range for slicing mean?

this means that the first index is included in the sequence and the last index is one after what is included

Lists are mutable, i.e. they can be changed

true

in a Boolean expression, any value except 0, " ", [ ], is considered"

true

how do you check the type of value you're using?

type(my_str)

what is an indentation error?

unexpected incident; need to have correct indentation

what is an input function?

used to take data from the person using your code that is then used throughout the program

how many bits are in one byte?

8 bits in one byte

how do you print a new line?

'\n'

how do you print a tab?

'\t'

What is a file?

a collection of data that is stored on secondary storage like a disk or a thumb drive

what is the difference between a compiler and an interpreter?

a compiler converts the entire program at one time and then executes in bulk an interpreter goes line by line

what is the syntax of slicing?

[start : finish : step] where start is the index of where we start the subsequence and finish is the index of one after where we end the subsequence

what is an 'except' suite?

it's activated if an error that occurs in the 'try' suite matches the type of exception

what does the "join" method do?

joins all the elements in consecutive indexes of a list into one string

what are the operations that can be performed on a list?

length concatenate repeat

what kind of operators are 'and', 'or', and 'not'?

logical operators

what is a compiler?

looks at each python instruction, one at a time, and turns that instruction into something that can be run

what makes a string invalid?

mixing up quotation types

what is a syntax error?

most basic type of error arise when the python parser is unable to understand a line of code almost always fatal

how do you copy a string?

my_str = 'hi mom' new_str = my_str[ : ]

how do you reverse a string?

my_str = 'hi mom' reverse_str = my_str[ : : -1]

what is the 'r' mode?

opens a file in read-only mode, initial position at the beginning of the file will give error message if file doesn't exist

what is computer hardware?

physical devices: processor, memory, keyboard, monitor, mouse, etc

what do triple quotes do?

preserves both the vertical and horizontal formatting of the string; allows you to type tables, paragraphs, etc and preserve the formatting

what does a rectangle represent in a flowchart?

process

what is an index error?

raised when you refer a sequence which is out of range try to call the fourth index when there's only three items

what determines true vs false for strings?

uses mapping and the assigned integers to each character, if a character has a higher assignment it's the larger element compare elements of strings if they're equal, moves to the next character in each if they're unequal, the relationship between those to characters are the relationship between the string if one ends up being shorter, but equal, the shorter is smaller

what is a type error?

when two unrelated types of objects are combined

what are keywords?

words or phrases in python that carry out a predetermined purpose


Conjuntos de estudio relacionados

Chapter 22: Nursing Care of the Child With an Alteration in Mobility/Neuromuscular or Musculoskeletal Disorder

View Set

Statistics : Chapter 1.5 BIAS IN SAMPLING

View Set

BUS2 - 130 Intro to Marketing (Chapter 4)

View Set

Kyle and Carman PrepU Chapter 26: Nursing Care of the Child With an Alteration in Metabolism/Endocrine Disorder

View Set

Business Law Ch.29: Personal Property & Bailments

View Set

Linear Algebra Assignments True/False

View Set

Česky krok za krokem 1, lekce 11: Cestování

View Set