第一个练习程序:序列乘法

···Python

sentence=input("Sentence:")

screen_width=80

text_width=len(sentence)

box_width=text_width+10

blank_width=(box_width-text_width)//2

left_width=(screen_width-text_width)//2

print(r'The sentence you input is in the box!')

print(' '*left_width+'+'+'-'*(box_width-2)+'+')

print(' '*left_width+'|'+' '*(box_width-2)+'|')

print(' '*left_width+'|'+' '*blank_width+sentence+' '*(box_width-text_width-blank_width-2)+'|')

print(' '*left_width+'|'+' '*(box_width-2)+'|')

print(' '*left_width+'+'+'-'*(box_width-2)+'+')

```

你可能感兴趣的:(第一个练习程序:序列乘法)