can anyone show me an example to find area of a rectangle using function | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

can anyone show me an example to find area of a rectangle using function

17th Apr 2019, 7:55 PM
Abdulla Maahil
Abdulla Maahil - avatar
4 ответов
0
here is an example with predefined variables. you could make it so that it accepts user inputs for length and width. you could also make the function return the result only and print it in another line of code, there are many possibilities. here is a basic one : def findArea(length, width) : area = length * width print("the area of the rectangle is : "+ str(area)) length = 4 width = 2 findArea(length, width)
17th Apr 2019, 9:40 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
in which programming language?
17th Apr 2019, 8:19 PM
Bahhaⵣ
Bahhaⵣ - avatar
17th Apr 2019, 8:48 PM
Abdulla Maahil
Abdulla Maahil - avatar
0
def findArea(length, width) : areaCurrent = length * width print("the area of the rectangle is : "+ str(areaCurrent)) length = 4 width = 2 findArea(length, width)
22nd May 2021, 8:17 AM
Diallo Aboubacar