MulaiMulai sekarang secara gratis

Calling lambda in-line

Remember, one of the key benefits of lambda is the ability to use functions in-line.

In this exercise, you'll modify the approach of the previous exercise to calculate the total file size in-line without storing a lambda function as a variable first.

Latihan ini adalah bagian dari kursus

Intermediate Python for Developers

Lihat Kursus

Petunjuk latihan

  • In a single line of code, make a lambda function that multiplies file_size by 1 + extra_space and returns the results.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

file_size = 2500
extra_space = 0.15

# Call a lambda function in one line
print((____ x: x * (1 + extra_space))(____))
Edit dan Jalankan Kode