Write a function which takes a number as argument and calculates its cube. If no no.is entered, then it calculates the cube of 2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a function which takes a number as argument and calculates its cube. If no no.is entered, then it calculates the cube of 2

12th Dec 2020, 8:18 AM
Kashish Juneja
Kashish Juneja - avatar
2 Answers
+ 2
Kashish Juneja #return the value from the function then print the returned value. def c(a=2): r =a*a*a return r n = eval(input('Enter a num: ')) if n==None: print(c()) else: print(c(n))
12th Dec 2020, 8:37 AM
noteve
noteve - avatar
0
def c(a=2): r =a*a*a print(r) return r n = eval(input('Enter a num: ') if n==None: c = c() else: c = c(n)
12th Dec 2020, 8:27 AM
Kashish Juneja
Kashish Juneja - avatar