Programming in Python - Unit 11 - Week 11 (Contents) - Input-Output
Programming in Python - Unit 11 - Week 11 (Contents) - Input-Output
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/CEC)
Course Assessment-11-2024
outline Assignment not submitted Due date: 2024-04-28, 23:59 IST.
https://onlinecourses.swayam2.ac.in/cec24_cs01/unit?unit=62&assessment=103 1/3
4/27/24, 10:36 PM Programming in Python - - Unit 11 - Week 11 (Contents): Input-Output
Manipulation Error
()
4) Which of the following is used to close a file in python? 1 point
Week 6
(Contents):
Introduction end()
to list. () terminate()
finish()
Week 7 close()
(Content):
Introduction
5) Which method is used to read a single line from the file? 1 point
to tuples. ()
Week 8 reads()
(Contents):
read()
Introduction
to readlines()
dictionaries () readline()
Week 11
7) What is the purpose of the with statement in Python file handling? 1 point
(Contents):
Input-Output
()
To create a new file
Lecture 1: File
Handling-I
(unit?
To open an existing file
unit=62&lesson
=63)
https://onlinecourses.swayam2.ac.in/cec24_cs01/unit?unit=62&assessment=103 2/3
4/27/24, 10:36 PM Programming in Python - - Unit 11 - Week 11 (Contents): Input-Output
unit=62&lesson
=65) To read the contents of a file
Lecture
Material (unit?
unit=62&lesson
To write data to a file
=66)
To set the current position in a file
Quiz:
Assessment- 9) How can you read the entire contents of a file named "data.txt" into a variable named 1 point
11-2024 content?
(assessment?
name=103)
content = open("data.txt").read()
content = read_file("data.txt")
10) Which of the following modes is used to open a file for reading and writing in Python? 1 point
r
w
a
r+
https://onlinecourses.swayam2.ac.in/cec24_cs01/unit?unit=62&assessment=103 3/3