Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Version 3.9.1 Questions: 1. Which of the following are methods of the file object? a) Tell b) size c) open d) read 2. Debug

Python Version 3.9.1 Questions:

1. Which of the following are methods of the file object?

a) Tell

b) size

c) open

d) read

2. Debug the following code

for I in items

print I

3. Debug the following code

if I < 3:

print I

4. What line is necessary in order to use regular expressions?

a) Use regex

b) import re

c) import sys

d) import regex

5. What does the following match?

^(ab)*$

a) fab

b) ababa

c) ab

d) blah

6. What's wrong with the following code?

f = open(file, w)

print f.read()

7. What is the effect of placing a comma at the end of a print statement?

Print this is a test,

8. What is output by the following print command?

Print %d %s %d%(32, hi, 45)

9. Consider the following interactive python example.

>>> info={}

>>> info["ok"]="Oklahoma"

>>> print info["ok"]

10. The variable info is a:

a) Tuple

b) String

c) Array

d) Dictionary

11. Which item is the key?

a) Info

b) ok

c) Oklahoma

d) print

12. Consider the code:

arr=[2,4,6,8,10]

for i in range(len(arr)):

print i * arr[i], " ",

What will be printed?

  1. 2 4 6 8 10
  2. 10 8 6 4 2
  3. 0 4 12 24 40
  4. 40 24 12 4 0

13. Consider the code:

arr=[2,4,6,8,10]

for i in range(2, 4):

print arr[i], " ",

What will be printed?

  1. 6 8
  2. 4 6
  3. 4 6 8
  4. 6 8 10

14. In Python, the value of a string cannot be modified, but a string variable can be made to refer to a different string value. Because of this property we say that strings are:

a) unchangeable

b) immodifiable

c) immutable

d) static

15. What does the following program print?

import re

p=re.compile("ab")

print p.sub("ee", "rabbit")

16. What does the following program print?

import re

p=re.compile("[to]")

print p.sub("from", "From here to Atoka.")

a) Frfromm here fromfrom Afromfromka.

b) From here from Atoka.

c) To here to Atoka.

d) From here from afromka.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

1. Traditional and modern methods of preserving food Articles ?

Answered: 1 week ago

Question

What is sociology and its nature ?

Answered: 1 week ago

Question

What is liquidation ?

Answered: 1 week ago

Question

Explain the different types of Mergers.

Answered: 1 week ago

Question

What did they do? What did they say?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago