Download Final exam review - NYU Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CSCI-UA.2-2 – Introduction to Computers and Programming - Python
Suggested List of Topics to Review for the Final Exam (Spring 2015) – Page Page 1 of 4
Introduction: Do you remember the old joke … “How do you get to Carnegie
Hall?” … The punch-line is “Practice, practice, practice!” The same is true
here. Practice writing programs at the computer; practice writing programs with a
pencil and paper and then type them into IDLE and run them to see your results;
running programs and watching how variables change as the program runs ...
these are the primary tools which will help you to study and to prepare for the
final exam … and beyond!
General Definitions and Concepts
1. syntax: What does syntax mean for a programming (rather than a natural)
language? Give examples in Python
2. operating system: What is it? Which ones are currently the most popular?
3. programming language: How many can you name?
4. structured programming: define
5. debugging: What is debugging? Can you describe it? How do you do it?
6. What does it mean to trace code?
7. comments in your code: How are they designated? What is the purpose?
8. import statements: Why are they used? What do they do? Give at least
three examples.
9. Blocks of code: what is a block of code? How are they written in Python?
Give at least five examples.
10. What is a statement? Give at least three examples.
11. algorithm: What is an algorithm ? How is it used? Give at least three
examples.
12. What is the difference between (parentheses), [brackets] and {curly
braces }? Which ones do you use and when? Give examples for all three.
Variables: define the following terms and give examples.
1. variables
2. data types: what are they? Name four. Which ones are used when?
3. initialization
4. assignment
5. = vs = = What is the difference?
6. operators: Name and define at least 11.
7. reserved words: What are they? How are they used? Name at least ten.
8. integer division: What is it and How is it used? Why is it important?
9. operator precedence: What is it? How does it work in python?
10. casting: What is it and how is it used in python?
11. shortcut operators: +=, *=, etc. How are these used?
12. What is a string?
CSCI-UA.2-2 – Introduction to Computers and Programming - Python
Suggested List of Topics to Review for the Final Exam (Spring 2015) – Page Page 2 of 4
Errors
1. We have seen examples of run-time errors, logic errors and syntax errors.
Which are which? How do you fix them? How do you find them?
2. Give examples of all three types of errors.
3. When would you use try / except / else? Why would you use this? Give an
example and show how you would use all three parts of the structure.
Control Structures
1. Sequence structure: what is it?
2. Selection structure: what is it? How is it used in Python?
3. Repetition structure (aka "iterative structure"): what is it? Give examples
in Python.
4. Boolean values: How are they used in iterative structures?
5. Nested statements: what are these? What does this imply? Give examples.
6. if, if/else, if/elif/else : When do you use which?
7. logical operators: List at least five. How are they used? What are the
results?
8. while loops: What are they and how are they used?
9. What are the three required components for all while loops? Give
examples.
10. What is an infinite loop? Give an example.
11. Define counter-controlled repetition and give an example.
12. Define sentinel-controlled repetition and give an example.
13. What is a for loop? How is it used? Give at least three examples.
14. What are the advantages and disadvantages of for loops over while loops?
Can every for loop be re-written as a while loop? Can every while loop be
re-written as a for loop? How do you know which one to use when?
15. What do "nested loops" refer to?
Functions
1. What is a function?
2. What information is in the first line of a function? And what is the first
line of a function called?
3. What is an argument or a parameter? How do you know the datatype of an
argument?
4. What is the significance of a return value? Is a return value always
required?
5. What does it mean to call or invoke a function?
6. What are local variables? Give an example.
7. What are global variables? Give an example.
8. What does scope refer to?
CSCI-UA.2-2 – Introduction to Computers and Programming - Python
Suggested List of Topics to Review for the Final Exam (Spring 2015) – Page Page 3 of 4
9. What is a module in Python? Why are they used? Which ones have we
used in class? How do you know when a module is in use?
Strings, Files, Lists and Dictionaries
1. What is string slicing? When and how do you use it? Give at least five
examples.
2. What does it mean to slice a list? Is it the same, roughly similar or
different from slicing a string?
3. What is the difference between negative and positive integers with respect
to a string slice?
4. What is the result when you use the list() function with a string? What
happens when you use split with a string? When would you use one over
the other?
5. What does it mean to open a file with the flag of “r”, “w”, or “a”?
6. What is a “.csv” file? How is it used? Where have you seen these before
using them with python?
7. What is a list? How is it used? Why is it used? Give at least five examples.
8. Which data types do lists support?
9. Describe the items in a list. How are they referenced?
10. What is an index? Which data type is used to reference items in a list?
11. Which data type is used to reference items in a dictionary?
12. What are some ways to assign values to lists? to a single value in a list?
the same value to an entire list? Give examples of each.
13. How are lists passed to functions? Give an example.
14. How are lists returned from a function? Give an example.
15. What does the following error message mean: IndexError: list index out of
range
16. How are lists copied?
17. What is a dictionary? How does it differ from a list? Give examples.
18. How do you know when to use a list and when to use a dictionary?
19. What are some ways to assign values in a dictionary? Give examples of
each.
20. Can a list be easily sorted? What about a dictionary? Give examples.
21. Can a list be easily randomized? What about a dictionary? Give examples.
More practice:
1. Write three questions we have not asked you yet … to ask the student
sitting next to you!
CSCI-UA.2-2 – Introduction to Computers and Programming - Python
Suggested List of Topics to Review for the Final Exam (Spring 2015) – Page Page 4 of 4
Python Command Index
This index will be included in your exam for you!
Core Language Elements and Functions
and
chr
def
del
elif
else
except
float
for
format
global
if
import
in
input
int
max
min
not
or
ord
print
range
return
str
try
while
List Methods
append()
index()
insert()
remove()
reverse()
sort()
Module Functions
random.randint()
math.sqrt()
String Testing
Methods
isalpha()
isdigit()
islower()
isupper()
isspace()
isalnum()
find()
String Manipulation
Methods
rstrip()
lstrip()
lower()
upper()
capitalize()
title()
swapcase()
replace()
split()
join()
File Object Methods
open
close
read
write
Dictionary Methods
get()
keys()
values()
Sample ASCII values
A
65
a
97
space
32
zero
48