Difference between revisions of "CSC111 Midterm Preparation 2014"
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | <onlydft> | ||
The midterm is closed-notes, closed-books, closed-computers. | The midterm is closed-notes, closed-books, closed-computers. | ||
+ | Note that depending on which textbook is used for CSC111, different topics are covered in different orders, and sometimes topics covered one semester before the midterm are covered after the midterm another semester. The purpose of this page is to give you an idea of the format that will be used and the type of questions to expect. '''Do not pay close attention to the actual Python constructs being tested.''' | ||
+ | <br /> | ||
<code><pre> | <code><pre> | ||
Line 21: | Line 24: | ||
What is the output of the following python program? | What is the output of the following python program? | ||
− | + | </pre></code> | |
+ | <source lang="python"> | ||
a = 3 | a = 3 | ||
b = 4 | b = 4 | ||
for a in range( b ): | for a in range( b ): | ||
− | print a, a+b | + | print( a, a+b ) |
− | + | </source> | |
+ | <code><pre> | ||
Problem #2: | Problem #2: | ||
Line 34: | Line 39: | ||
(tricky) | (tricky) | ||
+ | </pre></code> | ||
+ | <source lang="python"> | ||
print( "you win: " ) | print( "you win: " ) | ||
for i in range( -3, 0, -1 ): | for i in range( -3, 0, -1 ): | ||
print( "hip,", sep='-' ) | print( "hip,", sep='-' ) | ||
print( "hourrah!" ) | print( "hourrah!" ) | ||
+ | </source> | ||
+ | <code><pre> | ||
Problem #3: | Problem #3: | ||
Line 44: | Line 53: | ||
What is the output of the program below? | What is the output of the program below? | ||
+ | </pre></code> | ||
+ | <source lang="python"> | ||
Sum = 0 | Sum = 0 | ||
for i in range( 3 ): | for i in range( 3 ): | ||
Line 50: | Line 61: | ||
print( Sum ) | print( Sum ) | ||
− | + | </source> | |
+ | <code><pre> | ||
Problem #4: | Problem #4: | ||
Line 58: | Line 70: | ||
of the following list of words. | of the following list of words. | ||
+ | </pre></code> | ||
+ | |||
+ | <source lang="python"> | ||
L = [ "the", "quick", "red", "fox", 'jumped', 'over',\ | L = [ "the", "quick", "red", "fox", 'jumped', 'over',\ | ||
'the', 'lazy', 'brown', 'sleeping', 'dog' ] | 'the', 'lazy', 'brown', 'sleeping', 'dog' ] | ||
− | + | </source> | |
+ | <code><pre> | ||
In other words, the output for this list of words should be: | In other words, the output for this list of words should be: | ||
Line 77: | Line 93: | ||
What were the 2 numbers entered by the user? | What were the 2 numbers entered by the user? | ||
+ | </pre></code> | ||
+ | <source lang="python"> | ||
def f1( a ): | def f1( a ): | ||
b = 5 | b = 5 | ||
Line 89: | Line 107: | ||
a = input( "Enter first number? " ) | a = input( "Enter first number? " ) | ||
b = input( "Enter second number? " ) | b = input( "Enter second number? " ) | ||
− | print f1( b ), f2( a ) | + | print( f1( b ), f2( a ) ) |
main() | main() | ||
− | + | </source> | |
+ | <code><pre> | ||
Problem #6: | Problem #6: | ||
Line 138: | Line 157: | ||
What is your name? Alan Turing | What is your name? Alan Turing | ||
− | + | </pre></code> | |
− | + | <source lang="text"> | |
***************** | ***************** | ||
* * | * * | ||
Line 145: | Line 164: | ||
* * | * * | ||
***************** | ***************** | ||
− | + | </source> | |
+ | <code><pre> | ||
Here is another example: | Here is another example: | ||
Line 153: | Line 173: | ||
What is your name? Nabucodonosor, King of Babylon | What is your name? Nabucodonosor, King of Babylon | ||
− | + | </pre></code> | |
+ | <source lang="text"> | ||
************************************ | ************************************ | ||
* * | * * | ||
Line 159: | Line 180: | ||
* * | * * | ||
************************************ | ************************************ | ||
− | + | </source> | |
+ | <code><pre> | ||
</pre></code> | </pre></code> | ||
− | + | </onlydft> | |
<br /> | <br /> | ||
<br /><br /><br /><br /><br /> | <br /><br /><br /><br /><br /> | ||
[[Category:CSC111]][[Category:Exams]] | [[Category:CSC111]][[Category:Exams]] |
Latest revision as of 11:50, 2 September 2017