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 theyre 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(rE:201702PythonBlowing in the wind.txt,r+)
Problem 2
Given n, generate the first n row of Pascals triangle.
For example, given n = 5, Return
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
Reviews
There are no reviews yet.