日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

Coursera课程Python for everyone:chapter7

發(fā)布時(shí)間:2025/3/21 python 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Coursera课程Python for everyone:chapter7 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Chapter 7 Quiz

10?試題

1.?

Given the architecture and terminology we introduced in Chapter 1, where are files stored?

Main Memory

Machine Language

Secondary memory

Motherboard

2.?

What is stored in a "file handle" that is returned from a successful?open() call?

All the data from the file is read into memory and stored in the handle

The handle has a list of all of the files in a particular folder on the hard drive

The handle contains the first 10 lines of a file

The handle is a connection to the file's data

3.?

What do we use the second parameter of the?open() call to indicate?

The list of folders to be searched to find the file we want to open

Whether we want to read data from the file or write data to the file

How large we expect the file to be

What disk drive the file is stored on

4.?

What Python function would you use if you wanted to prompt the user for a file name to open?

file_input()

cin

read()

raw_input()

5.?

What is the purpose of the newline character in text files?

It enables random movement throughout the file

It indicates the end of one line of text and the beginning of another line of text

It adds a new network connection to retrieve files from the network

It allows us to open more than one files and read them in a synchronized manner

6.?

If we open a file as follows:

xfile = open('mbox.txt')

What statement would we use to read the file one line at a time?

for line in xfile:

while ((line = xfile.readLine()) != null) {

while (<xfile>) {

while line = xfile.gets 7.?

What is the purpose of the following Python code?

fhand = open('mbox.txt') x = 0 for line in fhand:x = x + 1 print x

Reverse the order of the lines in mbox.txt

Count the lines in the file 'mbox.txt'

Remove the leading and trailing spaces from each line in mbox.txt

Convert the lines in mbox.txt to lower case

8.?

If you write a Python program to read a text file and you see extra blank lines in the output that are not present in the file input as shown below, what Python string function will likely solve the problem?

From: stephen.marquard@uct.ac.zaFrom: louis@media.berkeley.eduFrom: zqian@umich.eduFrom: rjlowe@iupui.edu...

strip()

ljust()

find()

startswith()

9.?

The following code sequence fails with a traceback when the user enters a file that does not exist. How would you avoid the traceback and make it so you could print out your own error message when a bad file name was entered?

fname = raw_input('Enter the file name: ') fhand = open(fname)

setjmp / longjmp

try / catch / finally

try / except

signal handlers

10.?

What does the following Python code do?

fhand = open('mbox-short.txt') inp = fhand.read()

Checks to see if the file exists and can be written

Prompts the user for a file name

Reads the entire file into the variable?inp as a string

Turns the text in the file into a graphic image like a PNG or JPG

總結(jié)

以上是生活随笔為你收集整理的Coursera课程Python for everyone:chapter7的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。