Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Reverse
- num = int(input("Enter a number: "))
- reversed_num = 0
- while num > 0:
- digit = num % 10
- reversed_num = (reversed_num * 10) + digit
- num = num // 10
- print(f"The reversed number: {reversed_num}")
- #fibonacchi
- num_terms = int(input("Enter the number of terms for the Fibonacci series: "))
- if num_terms <= 0:
- print("Invalid input. Please enter a positive integer.")
- else:
- fib_series = [0, 1]
- while len(fib_series) < num_terms:
- fib_series.append(fib_series[-1] + fib_series[-2])
- sum_fib_series = sum(fib_series)
- print(f"The sum of the first {num_terms} terms in the Fibonacci series is: {sum_fib_series}")
- #armstrong
- num = int(input("Enter a number: "))
- original_num = num
- num_digits = len(str(num))
- sum_of_digits = 0
- while num > 0:
- digit = num % 10
- sum_of_digits += digit ** num_digits
- num = num // 10
- if original_num == sum_of_digits:
- print(f"{original_num} is an Armstrong number.")
- else:
- print(f"{original_num} is not an Armstrong number.")
- #positive negative sum
- sum_positive = 0
- sum_negative = 0
- for i in range(10):
- num = float(input(f"Enter number {i + 1}: "))
- if num > 0:
- sum_positive += num
- elif num < 0:
- sum_negative += num
- print(f"Sum of positive numbers: {sum_positive}")
- print(f"Sum of negative numbers: {sum_negative}")
- #palindrome
- num = int(input("Enter a number: "))
- original_num = num
- reversed_num = 0
- while num > 0:
- digit = num % 10
- reversed_num = (reversed_num * 10) + digit
- num = num // 10
- if original_num == reversed_num:
- print(f"{original_num} is a palindrome.")
- else:
- print(f"{original_num} is not a palindrome.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement