import random
def Calculate_Pi(total):
inside = 0
for i in range(0, total):
x2 = random.random() ** 2
y2 = random.random() ** 2
if x2 + y2 <= 1.0:
inside += 1
pi = (float(inside) / total) * 4
return pi
I want to change this def by using lambda
import random as r
total = int(input("total : "))
pi = lambda inside : float(len([x for x in range(total) if r.random()**2 + r.random()**2 <= 1.0]) / total) * 4
print(pi(total))
this is my code but i don't know this is right and i want to know any better code