• Nov 18, 2022 •AustinLeath
0 likes • 8 views
#Python 3: Fibonacci series up to n def fib(n): a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print() fib(1000)
• Oct 7, 2022 •KETRICK
0 likes • 4 views
x[cat_var].isnull().sum().sort_values(ascending=False)
• May 31, 2023 •CodeCatch
0 likes • 0 views
# 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)
• Sep 14, 2024 •rgannedo-6205
0 likes • 2 views
https://codecatch.net/post/06c9f5b7-1e00-40dc-b436-b8cccc4b69be
• Nov 19, 2022 •CodeCatch
0 likes • 1 view
def byte_size(s): return len(s.encode('utf-8')) byte_size('😀') # 4 byte_size('Hello World') # 11
def generate_pascals_triangle(num_rows): triangle = [] for row in range(num_rows): # Initialize the row with 1 current_row = [1] # Calculate the values for the current row if row > 0: previous_row = triangle[row - 1] for i in range(len(previous_row) - 1): current_row.append(previous_row[i] + previous_row[i + 1]) # Append 1 at the end of the row current_row.append(1) # Add the current row to the triangle triangle.append(current_row) return triangle def display_pascals_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 Pascal's Triangle: ")) # Generate Pascal's Triangle pascals_triangle = generate_pascals_triangle(num_rows) # Display Pascal's Triangle display_pascals_triangle(pascals_triangle)