• Sep 20, 2025 •cntt.dsc-f4b6
1 like • 2 views
print(123)
• Jun 1, 2023 •CodeCatch
0 likes • 4 views
from colorama import init, Fore # Initialize colorama init() print(Fore.RED + "This text is in red color.") print(Fore.GREEN + "This text is in green color.") print(Fore.BLUE + "This text is in blue color.") # Reset colorama print(Fore.RESET + "This text is back to the default color.")
• Sep 14, 2024 •rgannedo-6205
# Python binary search function def binary_search(arr, target): left = 0 right = len(arr) - 1 while left <= right: mid = (left + right) // 2 if arr[mid] == target: return mid elif arr[mid] < target: left = mid + 1 else: right = mid - 1 return -1 # Usage arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] target = 7 result = binary_search(arr, target) if result != -1: print(f"Element is present at index {result}") else: print("Element is not present in array")
• Feb 26, 2023 •wabdelh
0 likes • 1 view
#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)
• May 31, 2023 •CodeCatch
0 likes • 2 views
import random # Define the ranks, suits, and create a deck ranks = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'] suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] deck = [(rank, suit) for rank in ranks for suit in suits] # Shuffle the deck random.shuffle(deck) # Display the shuffled deck for card in deck: print(card[0], "of", card[1])
• Feb 23, 2025 •hasnaoui1
0 likes • 9 views
print("hello world")