提示:内容已经过期谨慎付费,点击上方查看最新答案

Python程序设计(英语)

  1. Which of the following matches type(1+2*3.14) ? ( )

  2. A: B: C: D:
    AI参考:选项C,,匹配“1+2*3.14”的类型,因为浮点数(float)可以包含小数。而整数(int)、长整数(long)和字符串(str)都不能包含小数,因此不匹配。所以正确答案是C。'
  3. The term applied to hiding details inside class definitions is ( )

  4. A:subclassing B:encapsulation C:obscuring D:documentation
    答案:John DonneAI参考:正确答案是 B:encapsulation。在类定义中隐藏细节的术语是封装,因此选项B“encapsulation”是正确答案。A选项“subclassing”是指子类化,表示类之间的继承关系;C选项“obscuring”是指隐藏、混淆;D选项“documentation”是指文档,与题意不符。'
  5. Which of the following statements is true ( )

  6. A:After the function is executed, the value of c is 210 B:After the function is executed, the value of c is 300 C:The function cannot be executed successfully D:After the function is executed, the value of a is 100
    答案:They perform rituals and get momentary relief from the anxiety.
  7. The method that allows us to access information from the instance variables of object is called ( ).

  8. A:mutator B:constructor C:stator D:accessor
    答案:Both of the aboveAI参考:答案D:Accessor。在这个问题中,选项A和B是与对象的属性设置和构造函数相关的方法,不符合问题的描述;选项C“stator”在此处并没有具体的意义或定义,不适用;选项D“accessor”是一种用于访问对象实例变量的方法,也就是用来获取或设置对象的属性值的方法,与问题的描述相符合。因此,答案为D,即accessor。'
  9. The items dictionary method returns a(n) ( )

  10. A:sequence of tuples B:dictionary C:bool D:int
    AI参考:在Python中,items()方法返回一个字典中所有项的键值对列表,因此它返回的是一个元组的序列(sequence of tuples)。所以,正确答案是A:sequence of tuples。'
  11. Li Hua forgot his QQ password, but he still remembered that the password was the ASCII code corresponding to his name “Li Hua”. Which of the following is the correct one? ( )

  12. A:77106327311898 B:74103277011595 C:75104277111696 D:76105327211797
    AI参考:正确答案是D:76105327211797。根据题干中的描述,Li Hua忘记了QQ密码,但记得密码是ASCII码对应他的名字“Li Hua”,因此选项中只有D选项的ASCII码与“Li Hua”对应,所以D选项是正确答案。'
  13. Which of the following is NOT a guideline for OOD? ( )

  14. A:All of the manipulation of the object’s data should be done through the methods. B:At each step in the design, try to find the simplest approach that will solve the problem. C:Candidate objects can be found by looking at the verbs in a problem description. D:Use top-down design to refine the nontrivial methods.
    AI参考:正确选项是C: Candidate objects can be found by looking at the verbs in a problem description。这个选项不符合OOD的指导原则,因为它的关注点是在问题描述中的动词,而不是面向对象的设计原则和对象之间的关系。其他选项A、B和D都是OOD的指导原则,A选项要求通过方法来对对象的数据进行所有的操作,B选项要求在设计过程中的每个步骤都尝试找到最简单的解决方案,D选项要求使用自顶向下的设计来改进非平凡的方法。C选项与OOD无关,因此是唯一不符合OOD指导原则的选项。'
  15. The output of the following function is ( )

  16. A:2 B:3 C:-1 D:1
    AI参考:正确答案是D:1。根据图像,该函数的输出为1。图像中的曲线表示函数图像,横坐标表示输入值,纵坐标表示输出值。图像中可以看出,当输入值为0时,输出值为1。因此,答案为D。'
  17. In top-down design, the subcomponents of the design are ( )

  18. A:functions B:programs C:loops D:objects
    AI参考:在顶层设计中,设计的子组件是:D: 对象。在顶层设计中,设计是由多个子组件组成的,这些子组件通常被称为“对象”。这些对象可以是任何东西,例如一个按钮、一个图像、一个文本框等。这些对象可以被视为设计中的基本组成部分,并且可以在设计过程中进行操作和修改。其他选项如功能、程序和循环都不是顶层设计中的子组件。'
  19. The value of math.sqrt(9) is ( )

  20. A:3 B:-3 C:9 D:3.0
    AI参考:答案为C:9。数学中,sqrt表示求平方根,所以9的平方根是3,所以答案是C。'
  21. (According to graphics.py) Which of the following method is provided to make a copy of a graphics object? ( )

  22. A:copy B:clone C:duplicate D:getMouse
    AI参考:正确答案是B:clone。在graphics.py中,提供了clone方法用于复制图形对象。A选项copy可能是另一个库或模块中的方法,而duplicate通常用于复制数据结构,如列表或字典。getMouse不是图形对象的方法。因此,B选项clone是正确的答案。'
  23. A multiple choice question is most similar to ( )

  24. A:an exception handler B:two-way decision C:simple decision D:multi-way decisions
    AI参考:单选题最类似于( )的选项是:B:two-way decision。因为单选题通常是一个简单的决策问题,只有一个正确答案,而two-way decision则表示有两个或多个可能的答案,这与单选题的特性相符。而其他选项A、C、D都不符合单选题的特性。A选项的exception handler通常用于处理异常情况,C选项的simple decision通常用于描述简单的决策过程,D选项的multi-way decisions通常用于描述多路径决策过程。因此,B选项two-way decision是最符合单选题特性的选项。'
  25. A loop pattern that continues until a special value is input is called a(n) ( )

  26. A:end-of-file loop B:infinite loop C:interactive loop D:sentinel loop
    AI参考:选项D“sentinel loop”是正确答案。一个持续运行直到特殊值输入的循环模式被称为“sentinel loop”,这里的“sentinel”是一个标志或标记,用于指示循环的结束。在许多编程语言中,sentinel通常是一个特殊的输入值,当该值被输入时,循环就会停止。因此,选项D“sentinel loop”是符合题目要求的正确答案。选项A“end-of-file loop”指的是文件结束时的循环,选项B“infinite loop”指的是无限循环,选项C“interactive loop”指的是交互式循环,这些选项都不符合题目要求。'
  27. Which of the following is NOT a dictionary method? ( )

  28. A:keys B:get C:sort D:clear
    答案:b97AI参考:选项A:keys不是字典方法。在Python中,字典是一种数据结构,用于存储键值对。keys()方法返回一个包含字典中所有键的迭代器。get()方法用于从字典中获取指定键对应的值。sort()方法用于对字典中的键或值进行排序。clear()方法用于清空字典中的所有键值对。因此,只有A选项不是字典方法。'
  29. (According to graphics.py) Which of the following returns the string of text that is currently in the entry box? ( )

  30. A:setText () B:setFace() C:getText () D:getAnchor ()
    AI参考:在graphics.py这个文件中,要返回当前在entry box中的字符串文本,应该使用getText()方法。所以,正确答案是C。setText()方法用于设置文本框中的文本内容。setFace()方法通常用于设置文本框中的字体样式。getAnchor()方法通常用于获取锚点信息,与文本框无关。因此,选项A、B和D都不符合题意。'
  31. The output of the following statements is ( )
    from math import sqrt
    print (sqrt(16) * 3 + 1 ==13)

  32. A:sqrt(16) * 3 + 1 ==13 B:True C:False D:13
    答案:They perform rituals and get momentary relief from the anxiety.AI参考:正确选项是 C:False。给出的代码片段是一个简单的比较语句,使用了Python的运算符和条件判断。语句“import math”导入了math模块,并使用了sqrt函数来计算16的平方根。然后,使用print语句输出结果并与13进行比较。由于sqrt(16) * 3的结果为4.8923,而4.8923 + 1的结果为5.8923,不等于13,因此输出结果为False。所以,选项C是正确的答案。'
  33. Which string method converts all the characters of a string to lower case? ( )

  34. A:upper B:capitalize C:small D:lower
    AI参考:正确答案是D:lower。lower方法是用来将字符串中的所有字符转换为小写字母的。其他选项中,upper是将字符串中的所有字符转换为大写字母的方法,capitalize是将字符串的第一个字符转换为大写字母,而small并不是一个标准的字符串方法。因此,答案为D。'
  35. Which of the following statement output 5.0? ( )

  36. A:round(4.6) B:float(4.6) C:int(4.9) D:float(5.2)
    AI参考:输出5.0的选项是A:round(4.6)。解释:* A: round(4.6) 会将4.6四舍五入为5.0。* B: float(4.6) 会将4.6转换为浮点数,输出结果为4.6。* C: int(4.9) 会将4.9转换为整数,输出结果为4。* D: float(5.2) 会将5.2转换为浮点数,输出结果为5.2。因此,只有A选项的输出为5.0。'
  37. Where mathematicians use subscripting, computer programmers use ( )

  38. A:slicing B:Python C:indexing D:caffeine
    AI参考:正确答案是C:indexing。在数学中使用下标的方法,程序员使用的是计算机编程语言中的索引功能,选项C中的“indexing”表示的就是索引的功能,因此选C。A选项的“slicing”是指切片,主要用于Python语言中,但也不是程序员使用的方式;B选项的“Python”是编程语言的一种,程序员并不会用它来进行下标操作;D选项的“caffeine”显然不是一种编程语言或技术,与问题无关。'
  39. (According to graphics.py) What color is color_rgb (255, 0, 0)? ( )

  40. A:magenta B:Yellow C:Blue D:Bright red
    AI参考:答案:A推理过程:红色(255, 0, 0)对应的颜色为Magenta,所以选A。'
  41. Which of the following is NOT one of the fundamental characteristics of object-oriented design/programming? ( )

  42. A:polymorphism B:inheritance C:encapsulation D:generality
    答案:
  43. How many times of loops does the following statement being executed? ( )

  44. A:4 B:5 C:7 D:6
    答案:
  45. Which expression is true approximately 66% of the time? ( )

  46. A:random() >= 66 B:random() < 66 C:random() >= 0.66 D:random() < 0.66
    答案:
  47. From a design standpoint, encapsulation separates the concerns of ( )

  48. A:“who” vs. “why” B:“who” vs. “how” C:“what” vs. “how” D:“what” vs. “why”
    AI参考:从设计的角度来看,封装是将“谁”和“为什么”的功能分离,正确答案是A。在面向对象的设计中,封装是一种重要概念,它将数据(变量)和操作数据的方法捆绑在一起,形成一个整体。这种封装方式将数据的访问和修改控制在一个特定的范围内,保护数据不被外界直接访问和修改,而是通过提供的方法来实现对数据的操作和控制。因此,“谁”指的是对象的实例或对象自身,“为什么”则指的是操作对象的原因或目的。从封装的角度来看,这两种功能的分离可以提高代码的可维护性和可复用性。因此,选项A“who” vs. “why” 是正确的答案。'
  49. Which of the following information is included in a function’s interface? ( )

  50. A:expected return values B:implementation details C:name D:parameters
    答案:organization of the comparison or contrast to support your ideas
  51. The following pseudocode demonstrates a(n) ( )

  52. A:event loop B:infinite loop C:loop and a half D:sentinel loop
    答案:伪码AI参考:正确选项是B:infinite loop。在给出的伪代码中,描述了一个无限循环,因此选项B“infinite loop”(无限循环)是正确的答案。选项A“event loop”(事件循环)和选项D“sentinel loop”(哨兵循环)与给出的伪代码描述不符。选项C“loop and a half”(半循环)可能是指一个半周期的循环,但与给出的伪代码描述也不符。'
  53. Instance variables go away once a method terminates. ( )

  54. A:错 B:对
    答案:ContingencyAI参考:答案是B:对。实例变量(instance variables)在方法执行结束后不会消失。实例变量是在类的外部定义的变量,它属于类中的每个对象,因此一个对象的实例变量在方法执行结束后仍然存在。这与局部变量不同,局部变量仅在方法的执行期间存在。因此,这个陈述是正确的。"
  55. The result of statement round(21.6) % 6 is 3.0. ( )

  56. A:对 B:错
    AI参考:答案是B:错。 round(21.6) % 6的结果应该是5.0,而不是3.0。在数学中,对一个浮点数执行模运算(%)通常返回一个整数结果。如果要对一个浮点数进行取整,可以使用round()函数或其他适当的取整函数。因此,这个判断题是错误的。"
  57. (According to graphics.py) Circle(Point(3,4), 10) constructs a circle with (3,4) as the center and 10 as the diameter. ( )

  58. A:对 B:错
    AI参考:答案:A。根据图形,Circle(Point(3,4),10)表示创建一个以(3,4)为中心,直径为10的圆。因此,这个判断题是正确的。"
  59. Python passes parameters by value. ( )

  60. A:错 B:对
    AI参考:答案是B:对。在Python中,参数是通过值传递的。这意味着当函数接收一个参数时,实际上是接收了该参数的值,而不是该参数本身。所以Python是按照值传递的,这就是答案B:对。"
  61. A top-down design is best implemented from the top down. ( )

  62. A:对 B:错
    答案:subtasksAI参考:答案是B:错。 根据题目中的描述,top-down设计是从上到下进行实施的,而题目中的陈述与之相反,因此选项B是正确的。所以题目表述错误。"
  63. Computers can generate truly random numbers. ( )

  64. A:对 B:错
    答案:Scheduled Reserved Instances预定的保留实例AI参考:对。计算机确实可以生成真正的随机数。随机数是指在不知道生成算法的情况下,无法预测的数字。计算机可以使用多种方法生成随机数,如使用物理现象(如噪声、闪电等)或通过数学方法(如伪随机数生成器)。因此,答案是A,对。"
  65. If the value being passed is a mutable object, then changes made to the object may be visible to the caller. ( )

  66. A:错 B:对
    AI参考:正确答案是【B:对】。 传递的值如果是可变对象,那么对对象进行的修改可能会被调用者看到。因此,这个判断题是正确的。"
  67. Typically, the design process involves considerable trial and error. ( )



  68. A:错 B:对
    答案:对
  69. An object may have only one instance variable. ( )

  70. A:错 B:对
    AI参考:正确答案是B:对。 在面向对象编程中,一个对象可以有多个实例变量,它们是对象的状态属性。因此,这个判断题的答案是B,即一个对象可以有多个实例变量。"
  71. (According to graphics.py) Oval(a,b) Constructs an oval in the bounding box determined by a and b. ( )

  72. A:错 B:对
    AI参考:正确答案是B:对。 根据图形库graphics.py中的Oval(a, b)函数,它会在由参数a和b确定的边界框中创建一个椭圆形。因此,这个判断题的答案是B,即“对”。"
  73. The condition x <= y <= z is allowed in Python. ( )

  74. A:错 B:对
    AI参考:答案是B:对。在Python中,条件表达式允许使用小于等于(<=)和大于等于(>=)等符号,因此选项B是正确的。"
  75. Modifying the list while looping through it can produce strange anomalies. ( )

  76. A:错 B:对
    答案:No effectAI参考:答案是B:对。在循环中修改列表可能会导致一些奇怪的异常情况。在循环中,列表的顺序可能会被改变,这可能会影响代码的执行结果。因此,在循环中修改列表不是一个好的做法。"
  77. In Python, 5.0 * 2 produces the same result as 5*2. ( )

  78. A:错 B:对
    答案:错
  79. Top-down design is also called stepwise refinement. ( )

  80. A:对 B:错
    答案:subtasksAI参考:答案:B 推理过程:Top-down design(自顶向下的设计)也被称为stepwise refinement(逐步细化),但是这两者是两个不同的概念,在UML设计方法中自顶向下的设计方法并不是逐步细化的过程。所以本题答案为B。 请注意,这里的解释是建立在特定的上下文和背景知识上的,对于那些不完全理解的情况下可能会有些模糊,如果你对自顶向下的设计和逐步细化之间具体有什么差异还有疑问,建议你参考更全面的相关文献资料来进一步理解和确认。"
  81. The parameters appearing in the function definition are called formal parameters, and the expressions appearing in a function call are known as actual parameters. ( )

  82. A:错 B:对
    答案:ltural movementAI参考:B:对。 在函数定义中出现的参数被称为形式参数(formal parameters),而在函数调用中出现的表达式被称为实际参数(actual parameters)。所以,这个说法是正确的。"
  83. There is usually only one correct solution to a problem involving decision structures. ( )

  84. A:对 B:错
    AI参考:答案是B:错。在涉及决策结构的问题中,通常存在多个正确的解决方案。决策结构通常涉及到多个因素和变量,因此对于同一问题可能有多种不同的解决方案。因此,这个判断题是错误的。"
  85. Python automatically converts numbers from one data type to another in certain situations. ( )

  86. A:错 B:对
    AI参考:正确答案是【对】。Python会在特定情况下自动将数字从一种数据类型转换为另一种数据类型。例如,整数可以自动转换为浮点数,反之亦然。Python还支持不同数据类型之间的其他转换,如将字符串转换为数字等。因此,这个陈述是正确的。"
  87. A developer should use either top-down or spiral design, but not both. ( )

  88. A:错 B:对
    AI参考:答案是“错”。开发人员应该根据项目的具体需求和团队的能力来选择适合的设计方法,而不是只使用其中一种设计方法。因此,选项A“错”是正确的答案。"
  89. Unicode uses the same codes as ASCII for the 125 characters originally defined. ( )

  90. A:错 B:对
    答案:正确AI参考:B:对。Unicode使用与ASCII相同的原始定义的前125个字符的代码。"
  91. In a Python class, the constructor is called __init__. ( )

  92. A:错 B:对
    答案:will be completedAI参考:正确答案是B:对。在Python类中,构造函数被命名为__init__。这是Python中的一种约定,用于标识类的构造函数。当创建一个新的对象时,Python会自动调用这个构造函数来初始化新对象的状态。"
  93. Functions that don't explicitly return a value return the special object Null. ( )

  94. A:对 B:错
    AI参考:答案:B:错。 这个判断题的意思是:没有明确返回值的函数会返回特殊的对象Null。这是错误的。在许多编程语言中,没有明确返回值的函数通常会返回一个默认值或者引发一个异常,而不是Null。因此,这个陈述是不准确的。"
  95. There is no difference between two string methods s.capitalize() and s.title(). ( )

  96. A:错 B:对
    答案:记得AI参考:答案:B:对。 根据题目中的描述,两个字符串方法s.capitalize()和s.title()没有区别。因为capitalize()方法会将字符串的第一个字母大写,而title()方法则是将字符串中的每个单词的首字母大写。所以,这两个方法在功能上是相同的,没有区别。因此,答案是B:对。"
  97. The easiest way to iterate through the lines of a file in Python is to use a while loop. ( )

  98. A:错 B:对
    AI参考:答案是B:对。在Python中,迭代文件中的每一行最简单的方法是使用while循环。这是一种正确的答案。"
  99. A Python dictionary is a kind of sequence. ( )

  100. A:对 B:错
    AI参考:答案是B:错。Python中的字典(dictionary)不是一种序列(sequence),而是一种映射(mapping)。字典是一种存储键值对的数据结构,它不遵循序列的顺序规则。因此,这个判断题是错误的。"

点赞(1) dxwkbang
返回
顶部