diff options
author | Nishanth Amuluru | 2010-10-07 10:57:15 +0530 |
---|---|---|
committer | Nishanth Amuluru | 2010-10-07 10:57:15 +0530 |
commit | a7f0f75b1ae8eb5e1cb0b205b01cf1333386f104 (patch) | |
tree | 4f6ac3d7d09d7d71361097f717e6e06c97cde3ae | |
parent | 42a039906cdcd6277b72c32c04c9125de940fc0a (diff) | |
download | st-scripts-a7f0f75b1ae8eb5e1cb0b205b01cf1333386f104.tar.gz st-scripts-a7f0f75b1ae8eb5e1cb0b205b01cf1333386f104.tar.bz2 st-scripts-a7f0f75b1ae8eb5e1cb0b205b01cf1333386f104.zip |
Added questions
-rw-r--r-- | input_output.rst | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/input_output.rst b/input_output.rst index 04969a2..4af7aa0 100644 --- a/input_output.rst +++ b/input_output.rst @@ -180,3 +180,109 @@ Thankyou Internal Reviewer 1 : Internal Reviewer 2 : External Reviewer : + +Questions +========= + + 1. ``a = 2.5``. What is the output of ``print "a is %d"%(a)`` + + a. a is 2.5 + #. a is 2.0 + #. 2.0 + #. a is 2 + + Answer: a is 2 + + 2. What does ``print "This is", "a line ", "with spaces"`` print? + + a. This is a line with spaces + #. This is a line with spaces + #. This is a line with spaces + #. This is a line with spaces + + Answer: This is a line with spaces + + 3. What does ``print "%2.5f"%(1.2)`` print? + + a. 1.2 + #. 1.20 + #. 1.20000 + #. 00001.2 + + Answer: 1.20000 + + 4. What is the output of the following code:: + + for i in range(1,10,2): + print i, + + Answer:: + + 1 3 5 7 9 + + 5. ``a = 2`` and ``b = 4.5``. What does ``print "a is %d and b is %2.1f"%(b, a)`` + print? + + a. a is 2 and b is 4.5 + #. a is 4 and b is 2 + #. a is 4 and b is 2.0 + #. a is 4.5 and b is 2 + + Answer: a is 4 and b is 2.0 + + 6. What is the prompt displayed by ``raw_input("Say something\nType here:")`` + + Answer:: + + Say something + Type here: + + 6. What is the prompt displayed by ``raw_input("value of a is %d\nInput b + value:"a)`` and ``a = 2.5`` + + Answer:: + + value of a is 2 + Input ba value: + + 7. ``a = raw_input()`` and user enters ``2.5``. What is the type of a? + + a. str + #. int + #. float + #. char + + Answer: str + + 8. ``a = int(raw_input())`` and user enters ``4.5``. What happens? + + a. a = 4.5 + #. a = 4 + #. a = 4.0 + #. Error + + Answer: Error + + 9. ``a = raw_input()`` and user enters ``"this is a string"``. What does + ``print a`` produce? + + a. 'this is a string' + b. 'this is a string" + c. "this is a string" + #. this is a string + + Answer: "this is a string" + +Problems +======== + + 1. Answer to universe and everything. Keep taking input from user and print it + back until the input is 42. + + Answer:: + + ip = raw_input() + while ip != "42": + print ip + + 2. |