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