Search Header Logo

Python Quiz-6

Authored by SACHIN VILAS NAGANE

University

Used 11+ times

Python Quiz-6
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following command is used to open a file “c:\temp.txt” in read-mode only?

infile = open(“c:\temp.txt”, “r”)

infile = open(“c:\\temp.txt”, “r”)

infile = open(file = “c:\temp.txt”, “r+”)

infile = open(file = “c:\\temp.txt”, “r+”)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following commands can be used to read “n” number of characters from a file using the file object <file>?

file.read(n)

n = file.read()

file.readline(n)

file.readlines()

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following commands can be used to read the next line in a file using the file object <tmpfile>?

tmpfile.read(n)

tmpfile.read()

tmpfile.readline()

tmpfile.readlines()

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these about a dictionary is false?

The values of a dictionary can be accessed using keys

The keys of a dictionary can be accessed using values

Dictionaries aren’t ordered

Dictionaries are mutable

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

a={1:5,2:3,3:4}

a.pop(3)

print(a)

{1: 5}

{1: 5, 2: 3}

Error, syntax error for pop() method

{1: 5, 3: 4}

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?