PYTHON QUIZ2

PYTHON QUIZ2

University - Professional Development

10 Qs

quiz-placeholder

Similar activities

KUIS PRAK. 9: MANAGEMENT FILE 😼

KUIS PRAK. 9: MANAGEMENT FILE 😼

University

10 Qs

X-Quiz #8

X-Quiz #8

University

13 Qs

Tes Awal AlPro Modul 6

Tes Awal AlPro Modul 6

University

10 Qs

PYTHON PROGRAMMING

PYTHON PROGRAMMING

University

10 Qs

Python pathlib module

Python pathlib module

Professional Development

11 Qs

Literasi Komputer

Literasi Komputer

University

14 Qs

Linux Commands

Linux Commands

University

11 Qs

Python Quiz-6

Python Quiz-6

University

10 Qs

PYTHON QUIZ2

PYTHON QUIZ2

Assessment

Quiz

Computers

University - Professional Development

Hard

Created by

MSK PSGRKCW

Used 9+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

1. Which of the following is correct with respect to the python code d = {"a":3,"b":7}?

Dictionary d is created.

a and b are the keys of dictionary d.

3 and 7 are the values of dictionary d

All of the above.

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

2. What will be the output of the Python code?

d1={"abc":5,"def":6,"ghi":7}

print(d1[0])

abc

5

{“abc”:5}

Error

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

3. What will be the output of the following Python code snippet?

>>> d = {"john":40, "peter":45}

>>> d["john"]

40

45

“john”

“peter”

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

4. Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?

d.size()

len(d)

size(d)

d.len()

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

5. What will be the output of the following Python code snippet?

a = {i: i * i for i in range(6)}

print (a)

Dictionary comprehension doesn’t exist

{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}

{0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}

{ 0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

6. To read two characters from a file object infile, we use ________.

infile.read(2)

infile.read()

infile.readline()

infile.readlines()

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

7. 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+”)

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?