Difference between revisions of "CSC111 Midterm Exam Preparation 2015"

From dftwiki3
Jump to: navigation, search
Line 79: Line 79:
 
</source>
 
</source>
 
Continue writing code that will output the number $5, $1, and quarters that makes up the amount entered by the user.  We assume the user can enter integer numbers or real numbers.  21 is a valid input.  7.76 is also valid.  For the first number, your program will output 4, 1, 0, indicating that 4 $5-bills, 1 $1-bill, and 0 quarters.  For the second number, the program will output 0, 1, 2, 3, indicating 0 $20-bills, 1 $5-bill, 2 $1-bill, and 3 quarters.
 
Continue writing code that will output the number $5, $1, and quarters that makes up the amount entered by the user.  We assume the user can enter integer numbers or real numbers.  21 is a valid input.  7.76 is also valid.  For the first number, your program will output 4, 1, 0, indicating that 4 $5-bills, 1 $1-bill, and 0 quarters.  For the second number, the program will output 0, 1, 2, 3, indicating 0 $20-bills, 1 $5-bill, 2 $1-bill, and 3 quarters.
 +
<br />
 +
=Question 9=
 +
<br />
 +
::<source lang="python">
 +
a = eval( input( "Enter a number" ) )
 +
 +
print( ...  )
 +
print( ...  )
 +
print( ...  )
 +
</source>
 +
<br />
 +
Assuming that the user enters the number 123.456789, complete the 3 print statements so that the output of the program becomes:
 +
<br />
 +
<source lang="text">
 +
a = 123.46#
 +
a =  ##123##
 +
a = 123.4568  #
 +
</source>
 +
<br />
 +
Note that there is 1 space between the equal sign and the number on the first line. There is also 1 space between the equal sign and the #-sign on the second line.  There is one space before and after the number on the third line.
 +
 +
 
<br />
 
<br />
  
  
 
</onlydft>
 
</onlydft>

Revision as of 20:13, 28 February 2015

--D. Thiebaut (talk) 18:08, 28 February 2015 (EST)


Midterm Exam Prep

The midterm is an in-class exam given under the rules of the honor code. It lasts 70 minutes. It will be closed books, closed notes, closed computers.



...