• May 31, 2023 •CodeCatch
0 likes • 0 views
# Prompt user for a decimal number decimal = int(input("Enter a decimal number: ")) # Convert decimal to binary binary = bin(decimal) # Convert decimal to hexadecimal hexadecimal = hex(decimal) # Display the results print("Binary:", binary) print("Hexadecimal:", hexadecimal)
• Nov 19, 2022 •CodeCatch
import math def factorial(n): print(math.factorial(n)) return (math.factorial(n)) factorial(5) factorial(10) factorial(15)
• Jun 16, 2024 •lagiath
0 likes • 1 view
print('hello, world')
# Deleting all even numbers from a list a = [1,2,3,4,5] del a[1::2] print(a)
• Nov 18, 2022 •AustinLeath
0 likes • 8 views
#question1.py def rose(n) : if n==0 : yield [] else : for k in range(0,n) : for l in rose(k) : for r in rose(n-1-k) : yield [l]+[r]+[r] def start(n) : for x in rose(n) : print(x) #basically I am printing x for each rose(n) file print("starting program: \n") start(2) # here is where I call the start function
# Python code to demonstrate # method to remove i'th character # Naive Method # Initializing String test_str = "CodeCatch" # Printing original string print ("The original string is : " + test_str) # Removing char at pos 3 # using loop new_str = "" for i in range(len(test_str)): if i != 2: new_str = new_str + test_str[i] # Printing string after removal print ("The string after removal of i'th character : " + new_str)