Comprehension

Color = ['Red', 'Green', 'Blue', 'Pink', 'Yellow', 'Magenta', 'Black']
def longcolors (_____,_______):# Fillline1
                with____________: # Fillline2
                         ____________: # Fillline3
                         ____________: # Fillline4
                         ____________: # Fillline5
fname = "Color.txť
n=int(input("Enter a number(4-7) :"))
 ______________# filline6
file = open(fname)
print(file.read())

Question: 1

Complete code for Fillline1 and Fillline6 so that Fillline6 invoke the longcolors functions by passing two arguments filename and integer n

Updated On: Apr 19, 2024
  • longcolors("colors", 5)
  • def longcolors("colors", 5)
  • def longcolors(n, frame):
    longcolors(n, frame)
  • def longcolors(frame, n)
    longcolors(frame, n)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

The correct option is(D): def longcolors(frame, n)
longcolors(frame, n)
Was this answer helpful?
0
0
Question: 2

Open the file for writing using a with statement in the file object namely myf.(fillline2)

Updated On: Apr 19, 2024
  • with open(frame, "w") as myf:
  • with open(frame, "w") as myfile :
  • with open(frame) as myfile :
  • with open(colors) as myfile :
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

The correct option is(A): with open(frame, "w") as myf:
Was this answer helpful?
0
0
Question: 3

Identify correct code for Fillline3 to create a loop so that each color is picked :

Updated On: Apr 19, 2024
  • for c in range(0, color):
  • for c in color:
  • For c in color:
  • for c in range(color)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

The correct option is(B):for c in color:
Was this answer helpful?
0
0
Question: 4

Inside the loop write code for Fillline4 and Fillline5 so that only colors from the color list get written in separate lines on the file that have word length more than n

Updated On: Apr 19, 2024
  • if len(c) > n
              myf.write(c)
  • if len(c) > = n :
           myfile.write(c+'\n')
  • if len(c) > n :
            myf.write(c+'\n')
  • if len(c) > n :
            myf.write(c)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

The correct option is(C):if len(c) > n :myf.write(c)
Was this answer helpful?
0
0
Question: 5

What will be the output if the value of n is entered as 5 ?

Updated On: Apr 19, 2024
  • Green
    Black
  • 4
  • Green
    Yellow
    Magenta 
    Black
  • Yellow
    Magenta
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

The correct option is(D):Yellow Magenta
Was this answer helpful?
0
0

Top Questions on Reading Comprehension

View More Questions