fork download
  1. course = "Python Programming"
  2. score = 95.5
  3. # 使用 f-string 拼接(注意原句没有空格在课程和成绩之间)
  4. sentence = f"{ course }课程的成绩是{score}分"
  5. print( sentence )
  6. # 输出score的数据类型
  7. print( type(score))
  8. # 将空格替换为下划线
  9. course_under = course.replace(" ", "_")
  10. print(course_under)
  11.  
  12. # 统计字母'o'出现的次数
  13. count_o = course.count('o')
  14. print("字母o出现的次数:", count_o )
Success #stdin #stdout 0.07s 14116KB
stdin
Standard input is empty
stdout
Python Programming课程的成绩是95.5分
<class 'float'>
Python_Programming
字母o出现的次数: 2