• Sep 6, 2020 •C S
0 likes • 3 views
def Fibonacci(n): if n<0: print("Incorrect input") # First Fibonacci number is 0 elif n==1: return 0 # Second Fibonacci number is 1 elif n==2: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2) # Driver Program print(Fibonacci(9))
• Nov 19, 2022 •CodeCatch
0 likes • 7 views
def when(predicate, when_true): return lambda x: when_true(x) if predicate(x) else x double_even_numbers = when(lambda x: x % 2 == 0, lambda x : x * 2) print(double_even_numbers(2)) # 4 print(double_even_numbers(1)) # 1
0 likes • 1 view
def print_pyramid_pattern(n): # outer loop to handle number of rows # n in this case for i in range(0, n): # inner loop to handle number of columns # values changing acc. to outer loop for j in range(0, i+1): # printing stars print("* ",end="") # ending line after each row print("\r") print_pyramid_pattern(10)
• Jul 8, 2025 •AustinLeath
0 likes • 5 views
from datetime import datetime epoch_time = 1753823646 # Example epoch time (March 15, 2023 00:00:00 UTC) # Convert epoch time to a UTC datetime object utc_datetime = datetime.utcfromtimestamp(epoch_time) print(f"Epoch time: {epoch_time}") print(f"UTC datetime: {utc_datetime}") # You can also format the output string formatted_utc_time = utc_datetime.strftime('%m-%d-%Y %H:%M:%S UTC') print(f"Formatted UTC datetime: {formatted_utc_time}")
• Feb 26, 2023 •wabdelh
#You are given a two-digit integer n. Return the sum of its digits. #Example #For n = 29 the output should be solution (n) = 11 def solution(n): return (n//10 + n%10)
• Sep 20, 2025 •cntt.dsc-f4b6
1 like • 2 views
print(123)