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