Download CPSC 217 Midterm Exam With 100% Verified And Correct Answers 2024 and more Exams Advanced Education in PDF only on Docsity!
CPSC 217 Midterm Exam With 100%
Verified And Correct Answers 2024
"Boring" Definition of a ______________ : A boxy device with a typewriter-like interface that stores and processes information. - Correct Answer-Computer "Criminal Code of Canada" Definition of a Computer : A "computer system" means a device that, or a group of interconnected or related devices one or more of which,
- contains ___________________________ or other data, and pursuant to computer programs (performs logic and control, and may perform any other function.) "Computer program" means data representing instructions or statements that, when executed in a computer system, causes the computer system to preform a function. - Correct Answer-computer programs "__________, USA" Definition of a Computer : An electronic device that accepts information in digital or similar form and manipulates it for a result based on a sequence of instructions. Another possibility:
- One who computes
- A tool that receives, processes, and presents data. - Correct Answer-UCITA Difference Engine (Charles Babbage)
- A difference engine is an automatic mechanical calculator designed to tabulate ______________________. (~1822)
- A mathematician, philosopher, inventor and mechanical engineer, Babbage originated the concept of a digital programmable computer.
- "father of the computer"
- In 1991, a functioning difference engine was constructed from Babbage's original plans. - Correct Answer-polynomial functions Difference Engine (_______________________)
- A difference engine is an automatic mechanical calculator designed to tabulate polynomial functions. (~1822)
- A mathematician, philosopher, inventor and mechanical engineer, Babbage originated the concept of a digital programmable computer.
- "father of the computer"
- In 1991, a functioning difference engine was constructed from Babbage's original plans. - Correct Answer-Charles Babbage
- Mathematician and writer
- Daughter of Lord Byron
- Worked with Charles Babbage -Maybe the first programmer (at least first evidence of)
- Early philosophy of computer science (The effects of technology on people) - Correct Answer-Ada Lovelace Ada Lovelace
- Mathematician and writer
- Daughter of Lord Byron
- Worked with Charles Babbage -Maybe the first programmer (at least first evidence of)
- Early philosophy of ______________________ (The effects of technology on people) - Correct Answer-computer science Modern Computers
- Integrated Circuits (1959) patent by __________________. Co-inventor of integrated circuit.
- William Shockley was the manager of a research group at Bell Labs that included John Bardeen and Walter Brattain. The three scientists were jointly awarded the 1956 Nobel Prize in Physics for "their researches on semiconductors and their discovery of the transistor effect."
- Considered founder of silicon valley, his company spawned Intel/AMD/National Semi conductors. - Correct Answer-Robert Noyce Modern Computers
- Integrated Circuits (1959) patent by Robert Noyce. Co-inventor of integrated circuit.
- _______________________ was the manager of a research group at Bell Labs that included John Bardeen and Walter Brattain. The three scientists were jointly awarded the 1956 Nobel Prize in Physics for "their researches on semiconductors and their discovery of the transistor effect."
- Considered founder of silicon valley, his company spawned Intel/AMD/National Semi conductors. - Correct Answer-William Shockley Modern Computers
- Integrated Circuits (1959) patent by Robert Noyce. Co-inventor of integrated circuit.
- William Shockley was the manager of a research group at Bell Labs that included John Bardeen and Walter Brattain. The three scientists were jointly awarded the 1956 Nobel Prize in Physics for "their researches on semiconductors and their discovery of the transistor effect."
- Considered founder of silicon valley, his company spawned Intel/AMD/National _______________________-. - Correct Answer-Semi Conductors
___________________:
- "The complexity for minimum component costs has increased at a rate of roughly a factor of two per year... Certainly over the short term this rate can be expected to continue, if not to increase. Over the longer term, the rate of increase is a bit more uncertain, although there is no reason to believe it will not remain nearly constant for at least 10 years." Gordon Moore 1965. - Correct Answer-Moore's Law Moore's Law:
- "The complexity for minimum component costs has increased at a rate of roughly a factor of two per year... Certainly over the short term this rate can be expected to continue, if not to increase. Over the longer term, the rate of increase is a bit more uncertain, although there is no reason to believe it will not remain nearly constant for at least 10 years." Gordon Moore ________. - Correct Answer- ____________________:
- Mathematician and Physicist
- Modern CPUs are based off of Von Neumann Architectures (1945). - Correct Answer- Von Neumann Von Neumann:
- Mathematician and Physicist
- Modern ________ are based off of Von Neumann Architectures (1945). - Correct Answer-CPUs What is ___________________?
- The scientific study of computation and computer technology, hardware and software.
- The study of the theoretical foundations of information and computation, and their implementation and application in computer systems.
- Combination of mathematics and engineering disciplines (even some philosophy). - Correct Answer-Computer Science "_____________________ is no more about computers than astronomy is about telescopes." Edsger Dijkstra. - Correct Answer-Computer science Areas in CPSC : __________________________________
- The technical side is important but also the users.
- The capabilities and weaknesses of the user need to be considered.
- How do we make a computer easy to use?
- User Interface Design
- How do we measure if an interface is "good"?
- Includes aspects of biology and behavioural sciences. - Correct Answer-Human- Computer Interaction (HCI) Areas in CPSC : _________________________________
- Producing realistic images using technology.
- Writing the programs that produce graphical effects rather than using those programs. (not about photoshopping images)
- Sub-areas of graphs: Animations (producing realistic motion), Rendering, Image processing (implementing graphical effects).
- Computer Vision: Focus is on interpreting and understanding visual information. Ex. of applications would be self-driving cars or AR. This does not produce images. - Correct Answer-Computer Graphics Areas in CPSC : __________________
- How can we get new information out of large dataset?
- Data mining? -> Figure out what you buy together at grocery stores. Amazon recommendations.
- Privacy of data? Netflix. -> Those fears were highlighted in December, 2010 when an in-the-closet lesbian mother used Netflix for privacy invasion, alleging the movie-rental company made it possible for her to be outed when it disclosed insufficiently anonymous information about nearly half-a-million customers as part of its $1 million contest. - Correct Answer-Databases Areas of CPSC : __________________________________
- Information Security (Ensure stored/transmitted information is confidential (prevent eavesdropping), authentic (comes from who it's supposed to), in its original form, etc...
- Privacy (Ensure only authorized entities can access data/information. Prevent accidental/malicious disclosure) - Correct Answer-Information Security and Privacy Areas of CPSC : Information Security and Privacy (_______________________)
- It can involve the creation of malicious software ('malware')
- Purpose: learn about how malicious software is created and distributed.
- Goal: develop countermeasures to protect computer systems.
- Understanding 'how things work' is one key component to designing more secure systems. (eg. creating viruses and other malware in order to create better defense against them.)
- But also the 'human' factor must be considered: some security experts think that many security breaches are due to user actions not technical flaws, ex. social engineering. (sometimes the "weakest line of defense" is not the technology but the person.)
- a sub-area : cryptography. (involved in the transmitting and storing sensitive information. the development of new and better approaches for encoding sensitive data to make unauthorized access harder.) - Correct Answer-Computer Security Areas of CPSC : _______________________________
- Two primary subfields : Complexity Theory and Computability Theory.
- Complexity Theory : How efficiently can the problem be solved. (Time & Memory Space). How is the efficiency impacted by the (size of) input that is supplied?
- Computability Theory: Can the problem be solved with a computer? Some things are not computable. (eg. halting problem) - Correct Answer-Theory of Computation
Areas of CPSC : ___________________
- Deals with networks surrounding one computer to networks that span the planet.
- How do we transfer data quickly? Do we need a consistent level of service?
- How do we transfer data reliably? Wirelessly?
- How do we get the data where it needs to go?
- Should network providers be allowed to inspect, filter or manipulate data?
- From the hardware level (fourier transforms, to intermediate layers like TCP/IP, to software layer like torrents) - Correct Answer-Networks Areas of CPSC : ____________________________
- How can we get multiple computers to work together to solve a problem? -> Representing the problem in a way that allows it to be solved in parallel. -> Coordinating actions (Dealing with race conditions/deadlock and Avoiding duplicate work.) - Correct Answer-Distributed Systems Areas of CPSC : ______________________________________
- How do we develop large software projects? -> How do we model the problem so that many people can work on it at once? -> How do we ensure that the software does what it is supposed to? -> How do we find and fix bugs in a large application? -> What design decisions can we make to ease future expansion?
- Employing systematic ways of producing good software on time and within budget.
- A typical person can only hold ~7 concepts in their mind at a time.
- A typical computer program consists of more than 7 'parts'.
- Consequently mechanisms for dealing with this complexity are needed -> Functional decomposition. - Correct Answer-Software Engineering Areas of CPSC : ________________________________
- Brings many areas together (Graphics, HCI, Networks, Distributed Systems, AI, Software Engineering) Frequently pushes the limits of these areas.
- What makes a game fun? -> How do we define fun? -> How do we measure fun? - Correct Answer-Game Development Artificial Intelligence (AI)
- Building a technology that is 'smart' or 'intelligent'
- Issue: ____________________________ -> There is some debate even among people in the field as to what constitutes 'intelligence' -> fact retrieval -> creativity -> problem solving ability -> many experts in this field would tend to agree that AI is about making technology that can think and behave like a person.
- Expert systems
-> Capturing the knowledge of a human expert as a set of rules stored in a database. -> The expert system can then answer questions, diagnose problems and guide decision making. -Example: -> Medicine -> IBM's Watson (Natural language processing. Won jeopardy including against Canadian Ken Jennings who had record of games own in a row. Also being applied to medicine) -> Computer or automative repair. - Correct Answer-what is intelligence?
-Building structures that function the way that neurons and their connections in the brain function.
- Neurons take electrical pulses as input and send electrical pulses as output.
- A required level of input is required before the output is 'fired'.
- This approach has been applied to problems which involve pattern recognition. (eg. visual, voice)
- Effectively like reducing the problem to some hidden function. - Correct Answer-Neural Networks Usage of CPSC in other Fields: ___________________________________________
- Use their Computational power to solve analytical problems faster.
- Asking a computer to design a building.
- The process was very time consuming and hard in the past when it had to be done manually.
- They weren't able to design complex structures because it was not possible to solve the analytical equations manually. - Correct Answer-Civil and Mechanical Engineering ____________________:
- A finite sequence of effective (unambiguous, possible) steps to solve a problem.
- Expressed in English, human-oriented form.
- Result of top-down design (or other problem solving strategy)
- A well written algorithm can be written in any compute programming language. - Correct Answer-Algorithm ______________________:
- The process of creating software by translating algorithms into a computer language.
- Algorithm: human readable form, layout/syntax is free as long as a reasonable person can understand it.
- Computer Program: computer readable form, precise syntax that must be followed exactly, will do exactly what you say (not what you meant!) - Correct Answer- Programming Programming:
- The process of creating software by translating algorithms into a computer language.
- Algorithm: human readable form, layout/syntax is free as long as a reasonable person can understand it.
- Computer Program: computer readable form, precise ______________ that must be followed exactly, will do exactly what you say (not what you meant!) - Correct Answer- syntax Programming Languages
- Many programming languages are available. Each offer different features, and has its own strengths and weaknesses.
- Common features : Allow us to control the behaviour of a computer.
- Syntactic Rule : What does a valid statement look like?
- _______________ Rule : What is the meaning of a statement? - Correct Answer- Semantic High vs. Low Level Languages.
- High: Human languages (Ambiguity, Redundancy)
- Low: Computer hardware. (___________________, Concise) - Correct Answer- Accuracy
- Takes ENTIRE program as input.
- Intermediate object code is generated
- conditional control statements are executed faster.
- memory requirement : more
- errors are displayed after entire program is checked - Correct Answer-Compiler
- takes SINGLE instruction as input
- no intermediate object code is generated
- conditional control statements are executed slower
- memory requirement : less
- errors are displayed for every instruction interpreted (if any) - Correct Answer- Interpreter Compiler or Interpreter
- Many modern languages use both processes
- They are first compiled into a lower level language, called a byte code, and then interpreted by a program called a ___________________.
- Python uses both processes, but because of the way programmers interact with it, it is usually considered an interpreted language. - Correct Answer-virtual machine Command Lines and Files
- _______________________ is a file containing your code often referred to as a program.
- The filename ends with a .py suffix.
- To execute on CPSC computers: python hello.py in the command prompt
- To save the output into a file: python hello.py > output.txt - Correct Answer-Source code
- Computers manipulate data of different types (eg. float, integer..)
- Used to store data in a particular format determined by the type.
- A piece of memory is allocated.
- The actual information and size of the info is determined by the type.
- Variables and the information in it will be destroyed when the program terminates. - Correct Answer-Variables Variables
- Some standard primitive variable types: -> Integer (eg. a=100) -> floating point (eg. b=3.14) -> strings (eg. str='Hello World!')
- Variable initialization: - =
- In Python, the format of the data also determines the ________ of the variable.
- Function "type" is used to find a variable type.
TRY: print(type("Hello, World!")) - Correct Answer-type Variable Naming
- Python naming convention: -> Names must start with a letter, can also start with underscore. -> A name may contain any letter, and number, and underscores. -> White spaces and signs with special meanings are not allowed.
- Case sensitive : "Sum" is different than "sum"
- Cannot use reserved keywords. Are these legal variable names? FooBar, X15Y, this_is_a_variable - Correct Answer-Yes Variable Naming
- Python naming convention: -> Names must start with a letter, can also start with underscore. -> A name may contain any letter, and number, and underscores. -> White spaces and signs with special meanings are not allowed.
- Case sensitive : "Sum" is different than "sum"
- Cannot use reserved keywords. Are these legal variable names? 42Bars, How Much, Foo-Bar, Var$ - Correct Answer-No
________________
- Variables whose values should not be changed.
- Can be any type. - Correct Answer-Constants Why use constants?
- Program becomes easier to understand and ____________
- All references to the constant can be changed by one single modification in constant initialization
- Using constants is another way for being intelligently lazy! - Correct Answer-maintain
- A combination of values, variables, operators, and calls to functions.
- Composed of operators and operands.
- Evaluation produce a result.
- Can appear on the right-hand side of assignment statements - Correct Answer- Expression Operators are special tokens that represent computations like addition, multiplication, and division. The values that operator works on are called _______________. Operates:
- +,-,*,/ are clear
- ** exponentiation
- // integer division
- % remainder - Correct Answer-operands Precendence:
- ()
- x**y
- -x, +x
- x*y, x/y, x%y, x//y
- x+y, x-y
- = What is the output of the following expression? 16-2*5//3+1 - Correct Answer-
- a built-in function to get an input from the user.
- sName=input("Please enter your name:")
- The obtained value will be stored in the variable in string form.
- You need to convert the value type if necessary. - Correct Answer-Input
- Refers to the structure of the program and the rules about the structure.
- Easiest to find, your program will not begin to run.
- Displays an error message and quit.
- The compiler/interpreter finds syntax errors. ex. print(77 - Correct Answer-Syntax Errors ________________ Errors
- does not appear until the program is run (harder to find)
- Also called exceptions - Correct Answer-Runtime _______________/Logic errors
- program will run successfully
- it does not produce the correct answer -it does what you told it to do
- hardest to find
- result of a wrong algorithm
- identifying is tricky - Correct Answer-Semantic
- notes and explanations in natural language
- intended only for the human reader
- completely ignored by the interpreter
token starts a comment - Correct Answer-Comments
What is __________________?
- Etymology : Latin, "to give form to" or 'to form an idea of"
- Definition : The state of being an object or system of interest. - Correct Answer- Information What is Data? Data: raw facts, representation of information, no context. __________________: The translation of information into data. - Correct Answer- Encoding Standard encoding scheme called _______________
- American Standard Code for Information Interchange
- 7 bits per character
- Includes printable characters
- Includes "control characters" that impact formatting (tab, newline), data transmission (mostly obsolete)
- Layout seems arbitrary, but actually contains some interesting patterns. - Correct Answer-ASCII Limitation of ASCII
- only supports ____________ character set
- No support for accents, additional character sets - Correct Answer-Latin
____________
- Variable length - 1,2,3 or 4 bytes per character.
- Compatible with ASCII
- Consider each byte
- Left most bit is 0
- Left most bits are 110? 2 byte character
- Left most bits are 1110? 3 byte character
- Left most bits are 11110? 4 byte character - Correct Answer-UTF- Encoding Images
- _____________ images : "line work" image is encoded as a collection of geometric primitives such as points, lines, curves.
- Raster images : constructed from a grid of pixels (picture elements), where each picture is assigned a color. - Correct Answer-Vector Encoding Images
- Vector images : "line work" image is encoded as a collection of geometric primitives such as points, lines, curves.
- ____________ images : constructed from a grid of pixels (picture elements), where each picture is assigned a color. - Correct Answer-Raster How do we represent color as a sequence of bits? Can represent almost any color as a combination of some red, some green, and some blue. Typically use a scale from 0 (no light of that color) to _______ (full on for that color). 16 million different possible colors. To represent an image: 3 color components for each pixel. - Correct Answer- Videos
- Raster image storage formats like jpg heavily use '____________________' to reduce storage size. -> Basic ideas, reduce quantity of colours stored, and group of ideas of 'where colours are' to store less information.
- Video compression works similar but since video is a sequence of frames where each frame is an image, they also make use of reducing data by grouping idea of 'colours stay the same and where' across multiple frames. -> great example of compression failure : confetti. -> when confetti is in image, the colour of spot changes every frame and nearby spots are different each frame. -> this means more info is needed per frame, as a result at the same data rate, the image quality will go down (boxy artifacts will appear, or even decoding breaks down) -> this is the same reason sports struggle with compressed video. - Correct Answer- compression
- The result of the relational operator (comparison) is of type bool (short for boolean)
- Boolean : a binary variable, having two possible values: "True" and "False".
- True-> 1 or T and False -> 0 or F - Correct Answer-Boolean Expression __________________ (Boolean) operators)
- For bool variables a and b -> a and b (True only when and b are both True) -> a or b (False only when a and b are both False) -> not A (True only when a is False and vice versa.) - Correct Answer-Logical "If" Statement Format
- The logical expression is evaluated -> If True, the indented statements that follow are executed. -> If False, the indented statements that follow will not be executed.
- The program continues. if (logical expression): (____________)Body - Correct Answer-indent If-elif-else
- You can always have an 'if' without 'elif' or 'else'
- You can't have 'elif' without '____' first
- You can't have 'else' with 'if' or 'elif' ahead
- You can only have one 'if' (in a chain)
- You can only have one 'else' (in a chain)
- You can have as many 'elif' as you desire (in middle of chain) - Correct Answer-if Namespace - is a declarative region that provides a ______________ to the identifiers (the names of types, functions, variables, etc,) inside it. Whenever you declare a variable it exists within a namespace. -Whenever python sees you use a variable, it looks with this storage area for the variable name you use and finds out what it is attached to. dir() returns to use all the things in the current namespace. - Correct Answer-scope ____________-box testing
- Test the program without looking at the source code -> Test are generally functional/behavioural - Correct Answer-Black ___________-box testing
- Design test cases for the program by looking at its source code
- Tests are generally structural - Correct Answer-White ____________-Box Test Coverage
How do we thoroughly do the cases test the code?
- Condition Coverage: Every decision point in the program is executed
- Statement Coverage: Every statement in the program is executed.
- Path Coverage: Every possible path through the program is executed. - Correct Answer-White White-Box Test Coverage How do we thoroughly do the cases test the code?
- ___________________ Coverage: Every decision point in the program is executed
- Statement Coverage: Every statement in the program is executed.
- Path Coverage: Every possible path through the program is executed. - Correct Answer-Condition Loop Terminology Body of the Loop: Simple or Compound statement that is repeated. Loop Condition: A ___________________ expression. Tested to determine if the loop will continue executing - Correct Answer-Boolean __________-test loops
- Checking the looping condition after executing the body of the loop
- The loop body executes at least one time - Correct Answer-Post ______-test loops
- Checking the looping condition before executing the body of the loop.
- The loop body executes zero or more times. - Correct Answer-Pre __________-test loops
- Initialize the loop control
- Execute the body of the loop (the part to be repeated)
- Update the loop control
- Check the condition
- False: Stop the loop and go to the rest of program.
- True: Repeat from step 2 Python does not provide this. - Correct Answer-Post _____-test loop
- Initialize the loop control
- Check the condition -False: Stop the loop, Skip the body go to the rest of program -True: Execute the body of the loop
- Update the loop control
- Repeat from step 2 - Correct Answer-Pre
______________________
- a variable used in the loop control statement
- loop control statement is a condition for loop execution
- python stops the loop execution when a condition is no longer true - Correct Answer- Loop Control While loop (________________________)
- executes as long as some condition is true
- a pre-tested loop (loop condition is tested before the loop executes the first time)
- when it is not known how many times to repeat while condition: (indent) body - Correct Answer-indeterminate While Loop Example userinput=int(input('Please enter a number to add to sum')) sum= while (userinput !=0) (indent) sum=sum+int(userinput) (indent)userinput=input('Plz enter a number, '0' to end') Here 0 is a _______________ value (a value that indicates loop completion) - Correct Answer-sentinel For loop (_____________________)
- A counting loop: Typically used when we know how many times we need to perform a task in advance. a pre-tested loop for variable_name in list: (indent) body - Correct Answer-determinate Range(start, end, step) is a function that can take up to 3 parameters and returns a range of integer values.
- start: is an optional parameter (default is 0) This represents the start of the range.
- end: is a required parameter, which represents the end of the range. The end value itself is ___________________ from the range.
- step: is an optional parameter (default is 1) It represents the increment value. - Correct Answer-excluded Step Values
- With one parameter: Counts from 0 up to (but not including) the number provided
- With two parameters: Counts from the first number to the second number (exclusive), increasing by one each time. This generates the ________________ if the second number is less than or equal to the first.
- With three parameters: Counts from the first number to the second (exclusive) increased by the third - Correct Answer-empty list What does range(5) return? Start= End= Step= - Correct Answer-0, 5, 1 What does range (1,6) return? Start= End= Step= - Correct Answer-1, 6, 1 What does range(0, 5, 2) return? Start= End= Step= - Correct Answer-0, 5, 2 What does the range (5) return? A range object representing.... - Correct Answer-0, 1, 2, 3, 4 What does range(1,6) return? A range object representing.... - Correct Answer-1, 2, 3, 4, 5 What does range (0, 5, 2) return? A range object representing... - Correct Answer-0, 2, 4
- entire loop ends immediately
- execution continues at the first statement after the loop body - Correct Answer-Break
- current iteration ends immediately
- execution returns to the top of the loop. In a for loop, the next item in the list is used. - Correct Answer-Continue
- Loops are powerful components in programming
- A loop can be the body of another loop, and so on.
- Different types of loops can be combined together. - Correct Answer-Nested Loops
- When the looping condition is always satisfied, the loop never ends.
- Caused by logical error: The loop control does not get updated. The update while always satisfy the loop condition. - Correct Answer-Infinite Loop
The looping condition is not met before entering the loop - Correct Answer-Erroneous Loops
- Make sure the loop executes the proper number of times
- Test conditions: Loop does not run. Loops runs exactly once. Loop runs exactly N times. - Correct Answer-Testing Loops
- Examine each statement in sequence
- Perform whatever tasks the statement requires, recording values of interest. Usually requires that the value of each variable is recorded.
- Result of tracing could be the value of one or more variables, or the output generated.
- Very important skill for debugging
- Can be done by hand, or by using print statements to display intermediate value during the execution of the loop - Correct Answer-Tracing