程序代写代做代考 python Problem 1

Problem 1

1) Create a file Blowing in the wind.txt, whose contents are:

How many roads must a man walk down
Before they call him a man
How many seas must a white dove sail
Before she sleeps in the sand
How many times must the cannon balls fly
Before they’re forever banned
The answer my friend is blowing in the wind
The answer is blowing in the wind

2) Insert the song name “Blowin’ in the wind” into the file head.

3) Insert the name of singer “Bob Dylan” after the song name.

4) Add the string “1962 by Warner Bros. Inc.” to the end of file.

5) Print the file contents on the screen.

f=open(r’E:\201702Python\Blowing in the wind.txt’,’r+’)

Problem 2

Given n, generate the first ‘n’ row of Pascal’s triangle.

For example, given n = 5, Return

[

[1],

[1,1],

[1,2,1],

[1,3,3,1],

[1,4,6,4,1]

]