class Person(object):
def say something(self)
print('hello')
print(result)
def say_something():
s = 'Hi'#sという変数を宣言
return s#sをsay_somethingという関数に返す
result = say_something()#say_something()という関数を呼び出したときに何かを返して欲しい
def what_is_this(color):#colorは変数(引数)
if color == 'red':
return 'tomato'
elif color == 'green':
return 'green pepper'
else:
return 'I do not know.'
result = what_is_this('red')#what_is_thisという関数(function)にredという文字列を代入する
print(result)
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme