0% found this document useful (0 votes)
3 views2 pages

Python Coding Questions With Solutions

The document provides solutions to common Python coding problems without using built-in functions. It includes functions for checking palindromes, generating Fibonacci series, checking prime numbers, calculating factorials, and determining Armstrong numbers. Each function is implemented with a clear algorithmic approach.

Uploaded by

rdhanush329
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python Coding Questions With Solutions

The document provides solutions to common Python coding problems without using built-in functions. It includes functions for checking palindromes, generating Fibonacci series, checking prime numbers, calculating factorials, and determining Armstrong numbers. Each function is implemented with a clear algorithmic approach.

Uploaded by

rdhanush329
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Top Python Coding Questions with Solutions (No Built-in Functions)

1. Palindrome Check
def is_palindrome(s):
reversed_str = ''
for i in range(len(s)-1, -1, -1):
reversed_str += s[i]
return s == reversed_str

2. Fibonacci Series
def fibonacci(n):
a, b = 0, 1
for i in range(n):
print(a, end=' ')
a, b = b, a + b

3. Prime Number Check


def is_prime(n):
if n <= 1:
return False
for i in range(2, n):
if n % i == 0:
return False
return True

4. Factorial of a Number
def factorial(n):
result = 1
for i in range(1, n + 1):
result *= i
return result

5. Armstrong Number
def is_armstrong(n):
original = n
result = 0
num_digits = 0
temp = n
while temp > 0:
num_digits += 1
temp //= 10
temp = n
while temp > 0:
digit = temp % 10
power = 1
for _ in range(num_digits):
power *= digit
result += power
temp //= 10
return result == original

You might also like