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

歡迎訪問 生活随笔!

生活随笔

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

python

Coursera课程Python for everyone:chapter3

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

Chapter 3

10?試題

1.?

What do we do to a Python statement that is immediately after an?if?statement to indicate that the statement is to be executed only when the?if?statement is?true?

Indent the line below the if statement

Begin the statement with a curly brace {

Start the statement with a "#" character

Underline all of the conditional code

2.?

Which of these operators is?not?a comparison / logical operator?

<=

>=

==

!=

=

3.?

What is true about the following code segment:

if x == 5 :print 'Is 5'print 'Is Still 5'print 'Third 5'

Depending on the value of?x, either all three of the print statements will execute or none of the statements will execute

The string 'Is 5' will always print out regardless of the value for?x.

The string 'Is 5' will never print out regardless of the value for?x.

Only two of the three print statements will print out if the value of?x?is less than zero.

4.?

When you have multiple lines in an?if?block, how do you indicate the end of the?if?block?

You use a curly brace { after the last line of the if block

You de-indent the next line past the if block to the same level of indent as the original?ifstatement

You capitalize the first letter of the line following the end of the if block

You omit the semicolon ; on the last line of the if block

5.?

You look at the following text:

if x == 6 :print 'Is 6'print 'Is Still 6'print 'Third 6'

It looks perfect but Python is giving you an 'Indentation Error' on the second print statement. What is the most likely reason?

Python has reached its limit on the largest Python program that can be run

In order to make humans feel inadequate, Python randomly emits 'Indentation Errors' on perfectly good code - after about an hour the error will just go away without any changes to your program

Python thinks 'Still' is a mis-spelled word in the string

You have mixed tabs and spaces in the file

6.?

What is the Python reserved word that we use in two-way if tests to indicate the block of code that is to be executed if the logical test is false?

otherwise

toggle

else

iterate

7.?

What will the following code print out?

x = 0 if x < 2 :print 'Small' elif x < 10 :print 'Medium' else :print 'LARGE' print 'All done'

All done

Small

All done

LARGE

All done

Small

Medium

LARGE

All done

8.?

For the following code,

if x < 2 :print 'Below 2' elif x >= 2 :print 'Two or more' else :print 'Something else'

What value of 'x' will cause 'Something else' to print out?

x = -2.0

x = -2

This code will never print 'Something else' regardless of the value for 'x'

x = 2.0

9.?

In the following code (numbers added) - which will be the last line to execute successfully?

(1) astr = 'Hello Bob' (2) istr = int(astr) (3) print 'First', istr (4) astr = '123' (5) istr = int(astr) (6) print 'Second', istr

2

5

1

6

10.?

For the following code:

astr = 'Hello Bob' istr = 0 try:istr = int(astr) except:istr = -1

What will the value be for?istr after this code executes?

It will be the 'Not a number' value (i.e. NaN)

false

-1

It will be a random number depending on the operating system the program runs on

總結

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

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