This commit is contained in:
2025-05-26 06:49:34 +08:00
parent e030d195b8
commit 88c8f2ca32
11 changed files with 19 additions and 11 deletions

View File

@@ -1,2 +1,3 @@
name = str(input('enter your name to check length : '))
# len()不止能够计算str的长度 它可以返回所有容器的长度
print('{0} name length is {1}'.format(name, len(name)))

View File

@@ -1,4 +1,5 @@
first_name = str(input('Enter your first name in lower-case : '))
surname = str(input('Enter your surname in lower-case : '))
# title就是把word转换为标题形式
compact = first_name.title() + ' ' + surname.title()
print(compact)

View File

@@ -1,4 +1,5 @@
rhyme = str(input('Enter the 1st. line of nursery rhyme : '))
start = int(input('Enter start number for display : '))
end = int(input('Enter end number for display : '))
# 截断字符串包含start位不包含end位
print('this is the 1st. line \n {0} \n and this is truncated {1}'.format(rhyme, rhyme[start:end]))