• 2021-04-14
    【其它】写出并理解下列语句输出的结果 s = "hello" print(s[0]) print(s[4]) print(s[-1]) print(s[0:3]) print(s[0:4:2]) print(s[:]) print(s[:3]) print(s[::-1]) print(s[1:])
  • h o o hel hl hello hel olleh ello

    内容

    • 0

      以下程序会报错的是( )。 A: s = ["a", "b", "c"] print(s[1]) B: s = ("a", "b", "c") print(s[1]) C: s = {"a", "b", "c"} print(s[1]) D: s = {0:"a", 1:"b", 2:"c"} print(s[1])

    • 1

      已知s="Python语言程序设计",则 print(s[1:4])的输出结果为( ), print(s[-3:-2])的输出结果为( ), print(s[-4:2])的输出结果为( ). 3分

    • 2

      s=”HelloWorld”,可以输出”World”子串的代码是() A: print(s[-5:]) B: print(s[-5:-1]) C: print(s[-5:0]) D: print(s[7:])

    • 3

      写出并理解下列语句输出的结果s="hello"print(s[0])print(s[4])print(s[-1])print(s[0:3])print(s[0:4:2])print(s[:])print(s[:3])print(s[::-1])print(s[1:])

    • 4

      若有定义s = 'Python is beautiful!' 则下列可以输出“python”的语句是___。() A: print(s[1:-14].lower()) B: print(s[0:6].lower) C: print(s[0:6]) D: print(s[-21:-14].lower())