[Python]错题集

来源:互联网 发布:软件源大全 编辑:程序博客网 时间:2024/06/06 19:20

Question 1

Which of the following results in a SyntaxError?
Your Answer ScoreExplanation"He said, "Yes!""Correct0.25 '''That's okay'''Correct0.25 '3\'Correct0.25 '"Once upon a time...", she said.'Inorrect0.00 Total 0.75 / 1.00

理解:单引号里面可以用双引号,但是不能用单引号

Question 2

The following is printed by a print function call:
hello-how-are-you
Select the function call(s) that prints what is shown above.
Your Answer ScoreExplanationprint('hello', 'how', 'are', 'you' + '-' * 4)Correct0.25 print('hello' + '-' + 'how' + '-' + 'are' + '-' + 'you')Correct0.25 print('hello-' + 'how-are-you')Correct0.25 print('hello', '-', 'how', '-', 'are', '-', 'you')Inorrect0.00 Total 0.75 / 1.00理解:print('hello','world')

     hello world  \\用,中间会自动产生空格

     print('hello'+'world')

     helloworld   \\如果用+中间空格不会自动产生


0 0
原创粉丝点击