fork download
  1. course="Python Programming"
  2. score=95.5
  3. sentence=f"{course}课程的成绩是{score}分"
  4. print(sentence)
  5. print(type(score))
  6.  
  7. course_under=course.replace(" ","_")
  8. print(course_under)
  9. count_o=course.count('o')
  10. print("字母o出现的次数:",count_o)
  11.  
  12. words=["python","ai","machine learning","data","nlp"]
  13. longest=words[0]
  14. for w in words:
  15. if len(w)>len(longest):
  16. longest=w
  17. print(f'最长的字符串是"{longest}",长度为{len(longest)}')
Success #stdin #stdout 0.11s 14120KB
stdin
Standard input is empty
stdout
Python Programming课程的成绩是95.5分
<class 'float'>
Python_Programming
字母o出现的次数: 2
最长的字符串是"machine learning",长度为16