Помогите исправить код | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Помогите исправить код

У меня уже жопа 5 день горит, я и так и сяк пробывал исправить код, но выходит одна и та же ошибка помогите плиз from math import pi radius = int(input()) p=0 a=0 def perim(p): p = 2*pi*radius def area(a): a = pi*radius**2 print("Perimeter:", round(perim(p), 2)) print("Area:",round(area(a), 2))

31st Dec 2020, 3:55 AM
Майкл Дориан
Майкл Дориан - avatar
5 Answers
+ 6
Вы забыли ключевое слово return для возврата значений из функции. (You forgot the return keyword to return values ​​from a function.) Я также меняю параметр, потому что параметр - это ваш радиус, а не результат. (I also change the parameter because the parameter is your radius, not the result.) р = 0 а = 0 Я также удалил эти два, потому что вам не нужно объявлять параметры вне функции. (I also removed those two because you don't need to declare parameters outside of the function.) (с помощью Google Translate) Your Code: https://code.sololearn.com/c7A18A1A15a2
31st Dec 2020, 4:06 AM
noteve
noteve - avatar
31st Dec 2020, 4:09 AM
Art1mis
+ 1
What should the output looks like? Can you give sample inputs and outputs? Thanks
31st Dec 2020, 4:22 AM
noteve
noteve - avatar
0
Thanks, everything works, but the task itself seems to have broken. Now everything is displayed correctly, but only the perimeter is displayed as the correct answer
31st Dec 2020, 4:15 AM
Майкл Дориан
Майкл Дориан - avatar
0
from math import pi radius = int(input()) def perim(): # место для вашего кода return def area(): # место для вашего кода return print("Perimeter:", round(perim(), 2)) print("Area:",round(area(), 2)) This is the source code I understood why the assignments task Russian and English are different. In this case, as the correct answer, you need an answer from the assignment in English. English task : You are given a program that takes the radius of a circle as the input. Complete the code to calculate the circle's perimeter and output the result. Remember, the perimeter of a circle = 2*pi*radius Sample Input 5 Sample Output 31.42 Russian task: Here is a program that takes the radius of a circle as input. Complete the code to display the perimeter and area values ​​of the circle. Input example 5 Output example Perimeter: 31.42 Area: 78.54 This is a bug
31st Dec 2020, 4:30 AM
Майкл Дориан
Майкл Дориан - avatar