【其它】写出并理解下列语句输出的结果 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
举一反三
- 写出下列程序的运行结果 s='abcdefg' print(s[3]) print(s[3:5]) print(s[:5]) print(s[3:]) print(s[::2]) print(s[::-1]) print(s[-2:-5])
- s = "Python", 能够显示输出Python 的选项是:()。 A: print s[0:-1] B: print s[-1:0] C: print s[:5] D: print s[:]
- s= HelloWorld 下面可以输出World字符串的是: A: print(s[-5:]) B: print(s[-5:-1]) C: print(s[-4:-1]) D: print(s[-5:0])
- s = " Python", 能够原样显示输出变量s值的选项是: A: print(s[:6]) B: print(s[-1:0]) C: print(s[:]) D: print(s[0:-1])
- 设有变量赋值s="Hello World",则以下选项中可以输出"World"子字符串的是()。 A: print(s[-5:-1]) B: print(s[-5:0]) C: print(s[-4:-1]) D: print(s[-5:])
内容
- 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())