私はPythonを初めて使用し、コマンドラインに入力せずに関数を実行するための「ドライバー」を表示されました。
ドライバーの概念や正しく入力する方法がわかりません。ドライバーの使用方法に関するフィードバックをお待ちしております。
私が理解していないのは、関数 makeGreyscaleThenNegate(pic) を入力して def 関数 makeGreyscaleThenNegate(picture) を呼び出す方法です: 入力値が (pic) と (picture) で異なる場合。(これは、「ドライバー」機能がどのように機能するかを知らないためだと思います。)
これが私が見せられたものです
def driverGrey():
pic=makePicture(pickAFile())
repaint(pic)
makeGreyscaleThenNegate(pic)
repaint(pic)
def makeGreyscaleThenNegate(picture):
for px in getPixels(picture):
lum=(getRed(px)+getGreen(px)+getBlue(px)/3
lum=255-lum
setColor(px,makeColor(lum,lum,lum))
私の信念は、これが機能することです.(pic)は、「ドライバー」関数を作成する前にすでに名前が付けられている/定義されているでしょうか? (pic) と (picture) がどのように同じファイルを参照しているのか、またはこれを完全に誤解しているのか、よくわかりません..