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

Python Questions Solutions

The document contains a series of Python programming questions and their corresponding solutions. It includes tasks such as printing names, generating multiplication tables, calculating factorials, and checking for prime numbers. Each question is followed by a code snippet demonstrating the solution.
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)
2 views2 pages

Python Questions Solutions

The document contains a series of Python programming questions and their corresponding solutions. It includes tasks such as printing names, generating multiplication tables, calculating factorials, and checking for prime numbers. Each question is followed by a code snippet demonstrating the solution.
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

Python Questions Solutions

Q1: Print your name 10 times


for i in range(10):
print("Your Name")

Q2: Print numbers from 1 to 10


for num in range(1, 11):
print(num)

Q3: Print even numbers from 1 to 20


for num in range(2, 21, 2):
print(num)

Q4: Multiplication table of a number


n = int(input("Enter a number: "))
for i in range(1, 11):
print(f"{n} x {i} = {n*i}")

Q5: Sum of first 10 natural numbers


total = 0
for num in range(1, 11):
total += num
print("Sum:", total)

Q6: Factorial of a number


n = int(input("Enter a number: "))
fact = 1
for i in range(1, n + 1):
fact *= i
print("Factorial:", fact)

Q7: Fibonacci series up to n terms


n = int(input("Enter number of terms: "))
a, b = 0, 1
for _ in range(n):
print(a, end=" ")
a, b = b, a + b

Q8: Check if a number is prime


n = int(input("Enter a number: "))
if n > 1:
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
print("Not Prime")
break
else:
print("Prime")
else:
print("Not Prime")

Q9: Reverse a number


n = int(input("Enter a number: "))
rev = 0
while n > 0:
rev = rev * 10 + n % 10
n //= 10
print("Reversed number:", rev)

Q10: Check if a number is palindrome


n = int(input("Enter a number: "))
if str(n) == str(n)[::-1]:
print("Palindrome")
else:
print("Not Palindrome")

You might also like