Mid-term Exam (2)
|
|
Date: December 2, 2014 |
78:62
91:69
86:71
80:74
79:77
(10%) Waht will be the output of the following program?
# curses library
import curses
stdscr = curses.initscr()
for i in range(10, 0, -1):
stdscr.move(i, i)
stdscr.addstr( "**********"[:i] )
stdscr.refresh()
curses.endwin()
(10%) Determine whether the following code has syntax errors or not. If it is correct, predict its output. If it is incorrect, point out the mistake(s).
# Boolean Operator
Q = True
P = False
print( not P or Q)
# Boolean Expressions as Decisions (P.255)
for p in ["True", "False"]:
for q in ["True", "False"]:
if ( p or q ):
print("The value is True.")