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. 3.1
  15. words = ["python","ai","machine learning","data","nlp"]
  16. longest=words[0]
  17. for w in words:
  18. if len(w)>len(longest):
  19. longest=w
  20. print(f'最长的字符串是"{longest}",长度为{len(longest)}')
Success #stdin #stdout 0.09s 14128KB
stdin
print
stdout
Python Programming课程的成绩是95.5分
<class 'float'>
Python_Programming
字母o出现的次数: 2
最长的字符串是"machine learning",长度为16