Professional Documents
Culture Documents
Tut12 Solutions
Tut12 Solutions
CO Mapping
1.
import turtle
2.
def display_file_characters(file_path):
try:
with open(file_path, 'r') as file:
# Read the content of the file
content = file.read()
selected_characters = content[start_position:end_position+1]
3.
New Delhi is the capital of India.
Hindi is the most widely spoken language of India.
India is a developing country.
Washington, D.C. is the capital of USA.
English is the primary language of USA.
USA is a developed country.
6.
This is student class
{'name': 'Amit', 'id': 101, 'age': 22}
__main__
7. Answer: b
Explanation: The output of the code shown above will be a single square. This is because the
function t.penup() is used to lift the pen after the construction of the first square. However, the
function t.pendown() has not been used to put the pen back down. Hence, the output shape of this
code is one square, of side 100 units.
8. d) Star
9. b) False
Explanation: In the code shown above, we have used the function t.penup() to life the pen
from the canvas. However, we have not used the function t.pendown() to keep the pen back
down. The function turtle.isdown() returns True if the pen is down and False if the pen is not
down. Hence the output is False.
Graphics and File handling
10.A. c) East
B. a)position()
Explanation: The functions fillcolor(), goto() and setheading() accept arguments, whereas the
function position() does not accept any arguments. The function position() returns the current
position of the turtle.
11.
Answer: b