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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Coursera课程Python for everyone:chapter5

發布時間:2025/3/21 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Coursera课程Python for everyone:chapter5 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Chapter 5

10?試題

1.?

What is wrong with this Python loop:

n = 5 while n > 0 :print n print 'All done'

This loop will run forever

The?print 'All done'?statement should be indented four spaces

There should be no colon on the?while?statement

while?is not a Python reserved word

2.?

What does the?break?statement do?

Jumps to the "top" of the loop and starts the next iteration

Exits the currently executing loop

Exits the program

Resets the iteration variable to its initial value

3.?

What does the?continue?statement do?

Exits the program

Jumps to the "top" of the loop and starts the next iteration

Resets the iteration variable to its initial value

Exits the currently executing loop

4.?

What does the following Python program print out?

tot = 0 for i in [5, 4, 3, 2, 1] :tot = tot + 1 print tot

5

0

15

10

5.?

What is the?iteration?variable in the following Python code:

friends = ['Joseph', 'Glenn', 'Sally'] for friend in friends :print 'Happy New Year:', friend print 'Done!'

friend

Glenn

Sally

friends

6.?

What is a good description of the following bit of Python code?

zork = 0 for thing in [9, 41, 12, 3, 74, 15] :zork = zork + thing print 'After', zork

Compute the average of the elements in a list

Find the smallest item in a list

Sum all the elements of a list

Count all of the elements in a list

7.?

What will the following code print out?

smallest_so_far = -1 for the_num in [9, 41, 12, 3, 74, 15] :if the_num < smallest_so_far :smallest_so_far = the_num print smallest_so_far

Hint: This is a trick question and most would say this code has a bug - so read carefully

-1

74

42

3

8.?

What is a good statement to describe the?is?operator as used in the following if statement:

if smallest is None :smallest = value

Is true if the?smallest?variable has a value of -1

matches both type and value

The if statement is a syntax error

Looks up 'None' in the?smallest?variable if it is a string

9.?

Which reserved word indicates the start of an "indefinite" loop in Python?

indef

while

break

for

def

10.?

How many times will the body of the following loop be executed?

n = 0 while n > 0 :print 'Lather'print 'Rinse' print 'Dry off!'

0

This is an infinite loop

5

1

總結

以上是生活随笔為你收集整理的Coursera课程Python for everyone:chapter5的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。