• 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
• Aug 1, 2025 •AustinLeath
0 likes • 2 views
from typing import Optional from datetime import datetime def convert_timestamp_string_to_epoch(timestamp: str) -> Optional[int]: epoch_time = None time_obj = datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f") epoch_time = int((time_obj - datetime(1970, 1, 1)).total_seconds() * 1000) return epoch_time print(int(convert_timestamp_string_to_epoch("2025-08-01 13:11:47.171"))) #above outputs 1754053907171.0 #how to I remove the .0 ?
• May 5, 2026 •CodeCatch
0 likes • 4 views
0 likes • 1 view
{"output":{"name":"format_final_json_response","arguments":{"output":{}}}}
def key_of_min(d): return min(d, key = d.get) key_of_min({'a':4, 'b':0, 'c':13}) # b
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword" ) mycursor = mydb.cursor() mycursor.execute("CREATE DATABASE mydatabase")