CS 1110 - Introduction to Programming
Review for Second Test
The following questions are provided to help you study for
the second test. Do not expect to see these exact questions on the test.
- In Python, what is a function?
- How do functions allow your programs to be more modular?
- When we pass a value to a function, what do we call that value? How do we actually pass it?
- What is a function definition? When does a function definition require that you put something inside its set of parentheses?
- How does a hierarchy chart require functions to be arranged?
- What is the scope of a variable? How does it affect commands that use that variable?
- What are the two types of variables that are based on their scope?
- How do you make a local variable? How do you make a global variable? How do you use it in a function?
- What is a parameter variable?
- What is a void function? What do you have to do to make one?
- How are constants implemented in Python?
- What is the import command used for in Python? How did you need to use it to generate random numbers?
- How should we write a line of code that calls a function stored in a library module?
- What is the secret to creating a function that returns a value?
- If a function returns two values, how should we write a line of code to receive them?
- When we ask a user to input a number, why might we want to cast it as an integer?
- Explain how to use the modulus operator to determine whether a number is even or odd.
- What function is used to create a file object in a Python program?
- What are the six modes that we discussed that can be used when opening a file?
- Name and explain some of the methods that are associated with file objects.
- In general, how can we tell when we have reached the end of a file we are reading?
- Why might you want to use a file object's name as the iterative in a for-in loop?
- What is an exception? What can we do in a program if we expect that one might happen?
- What is the basic structure of an exception handler?
- What is the purpose of a finally: suite?
- What is a sequence? What have we learned about in this class that would qualify as sequences?
- What notation is used to create and populate a list?
- How might we use the repetition operator to create a list of 12 zeros?
- Write a line of code that uses the range() function and the list() function to create a list of values running from 1 to 500.
- Write a loop to print each element in the list you created in the question above.
- Write a line of code that assigns a new value to the fifth
element in the list that was created in problem 29 above. Assign the
- What is the difference between using the del command and using the remove() method of a list?
- What does the index() method of a list take as an argument? What does it return?
- What would happen if you had a line of code that said list1 = list2?
- What is a file object? What does the writelines() method of a file object expect as an argument?
- What is the difference between a list and a tuple?