• Nov 19, 2022 •CodeCatch
0 likes • 0 views
# Deleting all even numbers from a list a = [1,2,3,4,5] del a[1::2] print(a)
• Jun 1, 2023 •CodeCatch
0 likes • 3 views
bytes_data = b'Hello, World!' string_data = bytes_data.decode('utf-8') print("String:", string_data)
0 likes • 2 views
from math import pi def rads_to_degrees(rad): return (rad * 180.0) / pi rads_to_degrees(pi / 2) # 90.0
• May 31, 2023 •CodeCatch
# Prompt user for base and height base = float(input("Enter the base of the triangle: ")) height = float(input("Enter the height of the triangle: ")) # Calculate the area area = (base * height) / 2 # Display the result print("The area of the triangle is:", area)
def check_prop(fn, prop): return lambda obj: fn(obj[prop]) check_age = check_prop(lambda x: x >= 18, 'age') user = {'name': 'Mark', 'age': 18} check_age(user) # True
0 likes • 1 view
filename = "data.txt" data = "Hello, World!" with open(filename, "a") as file: file.write(data)