Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Writing your own functions (2/5) | Functions
Learn Python from Scratch
セクション 7.  3
single

single

bookWriting your own functions (2/5)

メニューを表示するにはスワイプしてください

All we have learned till now can be used inside the function. For example, you can easily put conditional statements inside the function body.

For example, we can define a function that will check if the number is odd or even.

12345678910
# define a function def is_odd(n): if n % 2 == 0: return "even" else: return "odd" # testing function print('2 is', is_odd(2)) print('3 is', is_odd(3))
copy
タスク

スワイプしてコーディングを開始

Define a function is_positive checking if the number is positive (in that case return positive), negative (return negative), or equals zero (return zero).

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 7.  3
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt