Skip to content

Instantly share code, notes, and snippets.

View shahedpy's full-sized avatar
💙

Shahed Mohammad Hridoy shahedpy

💙
View GitHub Profile
nums = [5, 7, 9, 10]
squares = [x**2 for x in nums]
a = 5
b = 3
a, b = b, a
def is_palindrome(text: str) -> bool:
return text == text[::-1]
def is_armstrong(number: int) -> bool:
digits = str(number)
num_digits = len(digits)
total = sum(int(digit) ** num_digits for digit in digits)
return total == number
num = int(input("Enter a number: "))
if is_armstrong(num):
print(f"{num} is an Armstrong number.")
else:
def factorial(x):
if x == 1:
return 1
else:
return x * factorial(x-1)
print(factorial(5))
def isPrime(x):
if x < 2:
return False
elif x == 2:
return True
for n in range(2, x):
if x % n ==0:
return False
return True
@shahedpy
shahedpy / hello_world.py
Last active May 19, 2025 06:09
Python hello world program
print("Hello World!")