• 2022-07-27
    下列Python代码,函数的定义和调用书写正确的是()
    A: def test(a| b): print(a) print(b) test(1| 2)
    B: def test(a): print(a) print(b) test(1, 2)
    C: def test(a, b): print(a) print(b) test(1)
    D: def test(a, b): print(a) print(b) test(1, 2)
  • D

    内容

    • 0

      已知函数定义:def Test(*p): print(p)调用该函数Test(3, 5, 8),下面输出正确的是: A: (3, 5, 8) B: [3, 5, 8] C: 3, 5, 8 D: 3

    • 1

      阅读下面的程序:[br][/br]class Test:[br][/br]data1 = 10[br][/br]def __str__(self): return "data1 = %d" % (self.data1)[br][/br]test = Test()[br][/br]print(test)[br][/br]print(repr(test))[br][/br]上述程序最终执行的结果为()。 A: 面向对象.Test object at 0x101ca12e8>data1 = 10 B: 面向对象.Test object at 0x101ca12e8><面向对象.Test object at 0x101ca12e8 C: data1 = 10data1 = 10 D: data1 = 10

    • 2

      以下程序的输出结果,可能的选项是______。 ‪‪‪‪‪‪‪‪‪‪‪‫‪‪‪‪‪‫‫‪‪‪‪‪‪‪‪‪‪‪‪‫‪‪‪‪‪‪‪import random def test(): x = random.randint(0,10) y = random.randint(10,20) return(&#91;x,y&#93;) print(test())

    • 3

      Define a function as below with f as the function parameter,def test(f, a, b): print(f(a, b))Which of the following options will be the result of test((lambda x,y: x ** 3 + y), 2, 3)? A: 8 B: 9 C: 10 D: 11

    • 4

      下列关于Python中函数定义的代码正确的是?() A: def say_hello: print(Hello) B: def say_helloprint(Hello) C: def say_hello: print(Hello) D: def say_hello:print(Hello)