实验2 作业

    x1, y1 = 1.2, 3.57
    x2, y2 = 2.26, 8.7
    print('{:-^40}'.format('输出1'))
    print('x1 = {}, y1 = {}'.format(x1,  y1))
    print('x2 = {}, y2 = {}'.format(x2, y2))
    print('{:-^40}'.format('输出2'))
    print('x1 = {:.1f}, y1 = {:.1f}'.format(x1, y1))
    print('x2 = {:.1f}, y2 = {:.1f}'.format(x2, y2))
    print('{:-^40}'.format('输出3'))
    print('x1 = {:<15}, y1 = {:<15}'.format(x1, y1))
    print('x2 = {:<15}, y2 = {:<15}'.format(x2, y2))

s=input('Enter a string:')
      l=s.upper()
      print(l.replace('A',''))

  # 把姓名转换成大写,遍历输出
  name_list = ['david bowie', 'louis armstrong', 'leonard cohen', 'bob dylan', 'cocteau twins']

    n = 1
    for name in name_list:
      print(f'{n}: {name.title()}')
      n += 1
name_list = ['david bowie', 'louis armstrong', 'leonard cohen', 'bob dylan', 'cocteau twins']
name_list.sort()
n = 1
for name in name_list:
    print(f'{n}. {name.title()}')
    n += 1

x = input('请输入')
print(len(x.splitlines()))
print(len(x.split()))
print(len(x))
print(x.count(' '))

x = []
y = '我的愿望清单'
i = 0
while i < 3 :
    a = input('请输入想要加入愿望清单的事情:')
    x.append(a)
    i += 1
print('{:-^50}'.format(y))
n = 1
for str in x:
    print(f'{n}. {str}')
    n += 1

 

 

posted @ 2021-04-06 19:37  --艾合  阅读(56)  评论(3)    收藏  举报