下列程序运行后,输出结果为_________ count=0 for letter in 'Python': count=count+1 if letter == 'h': break print(count)
举一反三
- 使用for 语句把 Python 字符串的每个字母依次打印出来,下面哪个选项实现了() A: count=1 for letter in Python: print(“Python的第"+str(count)+"个字母是”+letter) count=count+1 B: count=1 for letter "Python”: print(“Python的第"+str(count)+"个字母是”+letter) count=count+1 C: count=1 for letter in "Python": print(“Python的第"+str(count)+"个字母是”+letter) count=count+1
- 下列程序的运行结果是( )。 count = 0 while count < 5: print(count, " is less than 5") count = count + 1 else: print(count, " is not less than 5")
- 请阅读下面的程序: count = 0 while count < 5: print(count, '小于5') if count == 2: break count += 1 else: print(count, "不小于5") 关于上述程序的说法中,描述错误的是
- count = 0 while count < 5: print (count, " 小于 5") count = count + 1 else: print (count, " 大于或等于 5")
- 执行下述代码: count = 5 def print_num(): count = 2 count += 1 print(count) 当调用print_num()函数时,输出结果为( )