CPTR Test 2
Know the following concepts. Understand where they apply and when they should or could be used.
All the Python programming concepts from the earlier chapters; for example, variables, assignment, arithmetic, and conditional statements with
if
andif/elif/else
,match
, and the conditional operatorLoops:
while
andfor
Producing sequences with the
range
objectAbnormal loop flow statements:
break
andcontinue
Standard Python functions we have studied:
randrange
,sqrt
, etc.Functions: defining, invoking, parameter passing, local variables, global variables, recursion, default arguments
Be able to do the following tasks.
Answer multiple choice, fill in the blank, and similar type questions. These mainly refer to simple coding examples.
"Playing computer;" that is, examining a code fragment or function invocation and determining what that code will do. This may be in the form of answering questions such as:
What is the value of the following expression?
What does the code print?
Given a section of code, be able to rewrite it so it behaves the same way but uses a different construct; for example, change one kind of loop into another kind of loop.
Be able to write a simple Python program given its specification. The code may involve any of the concepts in Chapters 1–7. Thus, in order to write the code you need to be able to do the following:
define and use variables
do arithmetic
construct conditional statements from scratch
construct loops from scratch
properly package code within a function consistent with provided specifications