Difference between revisions of "CSC111 Midterm Preparation 2014"
(Created page with ' <code><pre> CSC111 midterm exam preparation sheet Here are sample problems that will give you an idea of the type of questions you can expect for the midterm. No solution she…') |
|||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | <onlydft> | ||
+ | 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 10: | Line 14: | ||
short programs that will help you discover the answers. That too is a good | short programs that will help you discover the answers. That too is a good | ||
way to prepare for the exam! | way to prepare for the exam! | ||
+ | |||
+ | NOTE: The python programs were originally Version 2, and may not work | ||
+ | when you try them out. The idea here is to give you an idea of the type | ||
+ | of question to expect. | ||
Problem #1: | Problem #1: | ||
Line 16: | 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 29: | Line 39: | ||
(tricky) | (tricky) | ||
− | print "you win: " | + | </pre></code> |
+ | <source lang="python"> | ||
+ | print( "you win: " ) | ||
for i in range( -3, 0, -1 ): | for i in range( -3, 0, -1 ): | ||
− | print "hip,", | + | print( "hip,", sep='-' ) |
− | print "hourrah!" | + | print( "hourrah!" ) |
+ | </source> | ||
+ | <code><pre> | ||
Problem #3: | Problem #3: | ||
Line 39: | 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 | ||
for i in range( 3 ): | for i in range( 3 ): | ||
for j in range( i ): | for j in range( i ): | ||
− | + | Sum = Sum + j | |
− | |||
− | |||
+ | print( Sum ) | ||
+ | </source> | ||
+ | <code><pre> | ||
Problem #4: | Problem #4: | ||
Line 53: | 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 72: | 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 84: | 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 133: | Line 157: | ||
What is your name? Alan Turing | What is your name? Alan Turing | ||
− | + | </pre></code> | |
− | + | <source lang="text"> | |
***************** | ***************** | ||
* * | * * | ||
Line 140: | Line 164: | ||
* * | * * | ||
***************** | ***************** | ||
− | + | </source> | |
+ | <code><pre> | ||
Here is another example: | Here is another example: | ||
Line 148: | Line 173: | ||
What is your name? Nabucodonosor, King of Babylon | What is your name? Nabucodonosor, King of Babylon | ||
− | + | </pre></code> | |
+ | <source lang="text"> | ||
************************************ | ************************************ | ||
* * | * * | ||
Line 154: | Line 180: | ||
* * | * * | ||
************************************ | ************************************ | ||
− | + | </source> | |
+ | <code><pre> | ||
</pre></code> | </pre></code> | ||
+ | </onlydft> | ||
+ | <br /> | ||
+ | <br /><br /><br /><br /><br /> | ||
+ | [[Category:CSC111]][[Category:Exams]] |
Latest revision as of 11:50, 2 September 2017