• Jul 24, 2024 •AustinLeath
0 likes • 3 views
from statistics import median, mean, mode def print_stats(array): print(array) print("median =", median(array)) print("mean =", mean(array)) print("mode =", mode(array)) print() print_stats([1, 2, 3, 3, 4]) print_stats([1, 2, 3, 3])
• Nov 19, 2022 •CodeCatch
# Input for row and column R = int(input()) C = int(input()) # Using list comprehension for input matrix = [[int(input()) for x in range (C)] for y in range(R)]
• Jun 1, 2023 •CodeCatch
0 likes • 4 views
bytes_data = b'Hello, World!' string_data = bytes_data.decode('utf-8') print("String:", string_data)
• May 31, 2023 •CodeCatch
0 likes • 0 views
# Function to check Armstrong number def is_armstrong_number(number): # Convert number to string to iterate over its digits num_str = str(number) # Calculate the sum of the cubes of each digit digit_sum = sum(int(digit) ** len(num_str) for digit in num_str) # Compare the sum with the original number if digit_sum == number: return True else: return False # Prompt user for a number number = int(input("Enter a number: ")) # Check if the number is an Armstrong number if is_armstrong_number(number): print(number, "is an Armstrong number.") else: print(number, "is not an Armstrong number.")
• Mar 10, 2021 •Skrome
0 likes • 2 views
color2 = (60, 74, 172) color1 = (19, 28, 87) percent = 1.0 for i in range(101): resultRed = round(color1[0] + percent * (color2[0] - color1[0])) resultGreen = round(color1[1] + percent * (color2[1] - color1[1])) resultBlue = round(color1[2] + percent * (color2[2] - color1[2])) print((resultRed, resultGreen, resultBlue)) percent -= 0.01
• Nov 18, 2022 •AustinLeath
0 likes • 6 views
# Python Program to calculate the square root num = float(input('Enter a number: ')) num_sqrt = num ** 0.5 print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))