• Oct 7, 2022 •KETRICK
0 likes • 4 views
x[cat_var].isnull().sum().sort_values(ascending=False)
• Nov 18, 2022 •AustinLeath
0 likes • 1 view
# importing the modules import os import shutil # getting the current working directory src_dir = os.getcwd() # printing current directory print(src_dir) # copying the files shutil.copyfile('test.txt', 'test.txt.copy2') #copy src to dst # printing the list of new files print(os.listdir())
• May 31, 2023 •CodeCatch
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)
• Jul 2, 2025 •AustinLeath
import calendar from datetime import datetime # Get the UTC timestamp a = calendar.timegm(datetime.utcnow().utctimetuple()) print(a)
• Mar 12, 2021 •mo_ak
prime_lists=[] # a list to store the prime numbers def prime(n): # define prime numbers if n <= 1: return False # divide n by 2... up to n-1 for i in range(2, n): if n % i == 0: # the remainder should'nt be a 0 return False else: prime_lists.append(n) return True for n in range(30,1000): # calling function and passing starting point =30 coz we need primes >30 prime(n) check=0 # a var to limit the output to 10 only for n in prime_lists: for x in prime_lists: val= n *x if (val > 1000 ): check=check +1 if (check <10) : print("the num is:", val , "=",n , "* ", x ) break
• Nov 19, 2022 •CodeCatch
0 likes • 3 views
def clamp_number(num, a, b): return max(min(num, max(a, b)), min(a, b)) clamp_number(2, 3, 5) # 3 clamp_number(1, -1, -5) # -1