michael4227 / OIM3640-2021fall

Python
0 stars 0 forks source link

Exercises in Iterations #6

Closed lzblack closed 2 years ago

lzblack commented 3 years ago

Where is variable y coming from? https://github.com/michael4227/OIM3640/blob/4754539b1585eb00392381ba940fc590991045fe/session08/test_square_root.py#L13

michael4227 commented 3 years ago

Hi professor! I changed the order of the code and reformatted the outcome, now the code works. Could you please show me how I can format the heading in line 8(attached below) to let it match with the content of the table?

print(f'a , mysqrt(a) , math.sqrt(a) , diff \n')

lzblack commented 3 years ago

https://github.com/OIM3640/oim3640/blob/main/session08/exercises/mysqrt.py#L36-L38

michael4227 commented 3 years ago

哦哦 那所以如果title全是字符的话是没有办法用“:一个数字”这种命令来定义长度的,只能数空格输入空格让他们对齐咯?

lzblack commented 3 years ago

哦哦 那所以如果title全是字符的话是没有办法用“:一个数字”这种命令来定义长度的,只能数空格输入空格让他们对齐咯?

我猜你是问:如果不是 variable,可不可以用 {:} in f-string. 其实也可以的,例子: image

michael4227 commented 2 years ago

收到,谢谢老师!用tabulate这个library来控制打印的格式就好看很多!