Midterm exam topics

Download Report

Transcript Midterm exam topics

Midterm Exam Topics
(Prof. Chang's section)
CMSC 201
Midterm Topics
•
•
•
•
•
•
Variables
assignment
expressions
types
strings
lists
• input function
• print function
• Unix commands
•
•
•
•
Boolean expressions
if statements
nested if statements
cascading if statements
• while loops
• for loops
• nested loops
Not on Midterm
• Base conversion
• Emacs
• Intentional syntax errors
The answer is never "There's no output because the
program has a syntax error"
• functions
• Python 2
Tasks on Midterm
You may be asked to:
• produce the output of a program fragment
• trace the execution of a program
• write small programs
• use input( ) and print( ) functions
• use lists and strings
Variables, assignments,
expressions & type
• Python variables are not typed, but Python values have
•
•
•
•
type.
Types you need to know:
integer, float, string, list, boolean.
Trace through a program fragment and figure out the
value stored in a variable.
Be familiar with operators: +, –, *, /, **, //, %
Operator precedence
Strings and Lists
•
•
•
•
Know the difference between strings and lists.
Lists can have items of different type.
Use [ ] for indexing and slicing
Work with strings and lists using a for loop and/or a
while loop.
• + operator on strings and lists
• .append( ) method for lists
input() and print()
• Be able to write programs with input and print
• Use print with and without newlines
• Work with return values from input (Python 3).
Unix commands
cd
change directory
ls
list files in current directory
mkdir
make new directory
Boolean Expressions
• True and False in Python
• Relational operators: <
<=
==
>=
>
• Boolean operators: and or not
• Short circuit evaluation
• Can store Boolean values using assignment
if statements
• if statements with and without an else part
• nested if statements
• cascading if statements using elif
• write program fragments using if statement
while & for
• trace program fragments and write down output
• write your own program fragments with while / for
• work with strings and lists
• nested while and for loops
• for loops using range( )
• for loops using: for item in aList:
format
• Some True/False questions (no partial credit)
• Some multiple choice questions (no partial credit)
• Some short responses
• Some long responses (write a program)