• Nov 18, 2022 •AustinLeath
0 likes • 4 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))
• Jun 1, 2023 •CodeCatch
0 likes • 3 views
bytes_data = b'Hello, World!' string_data = bytes_data.decode('utf-8') print("String:", string_data)
• Sep 9, 2023 •AustinLeath
0 likes • 24 views
print("test")
0 likes • 1 view
filename = "data.txt" data = "Hello, World!" with open(filename, "a") as file: file.write(data)
• Nov 19, 2022 •CodeCatch
0 likes • 0 views
# Python code to find the URL from an input string # Using the regular expression import re def Find(string): # findall() has been used # with valid conditions for urls in string regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))" url = re.findall(regex,string) return [x[0] for x in url] # Driver Code string = 'My Profile: https://codecatch.net' print("Urls: ", Find(string))
• May 31, 2023 •CodeCatch
def generate_floyds_triangle(num_rows): triangle = [] number = 1 for row in range(num_rows): current_row = [] for _ in range(row + 1): current_row.append(number) number += 1 triangle.append(current_row) return triangle def display_floyds_triangle(triangle): for row in triangle: for number in row: print(number, end=" ") print() # Prompt the user for the number of rows num_rows = int(input("Enter the number of rows for Floyd's Triangle: ")) # Generate Floyd's Triangle floyds_triangle = generate_floyds_triangle(num_rows) # Display Floyd's Triangle display_floyds_triangle(floyds_triangle)