+ 1

Even nums 1-100 in multiple ways

Hi all, I like this possibility of solving one task in multiple ways. For start I prepared this bit of code with 3 ways to display even numbers in range 1-100. Maybe you have some other interesting suggestions? https://sololearn.com/compiler-playground/ccDNuh8sd0mp/?ref=app

18th Jun 2024, 9:20 AM
Paweł Dudek
4 Respuestas
+ 7
Paweł Dudek , Using slicing... you can print even numbers in given range...try this... https://sololearn.com/compiler-playground/c1Vat23YX7m1/?ref=app
18th Jun 2024, 10:26 AM
Riya
Riya - avatar
18th Jun 2024, 4:28 PM
Per Bratthammar
Per Bratthammar - avatar
+ 4
#This would print even whole numbers in floating point import math as M print(*map(lambda x:(x-~x-M.e**(0+M.pi*1j)).real, range(100>>1)))
19th Jun 2024, 6:19 AM
Brian
Brian - avatar
+ 3
for i in range(51): print(i<<1)
18th Jun 2024, 3:53 PM
Brian
Brian - avatar