Practice Questions Python
Practice Questions Python
------------------------------------
a=input("Enter numbers")
list=[int(i) for i in a.split()]
for j in list:
print(j**2)
------------------------------------
#Write a program in python to print Fibonacci series of 10 numbers.
a=0
b=1
print(a)
print(b)
for i in range(8):
c=a+b
print(c)
a=b
b=c
rev=0
while n!=0:
r = n % 10
rev=rev*10+r
n=n//10
if a>0:
elif a<0:
else:
d=len(str(n))
a=n
m=0
while n!=0:
r=n%10
m=m+r**d
n=n//10
if a==m:
else:
12
123
1234
12345
for i in range(1,6):
for j in range(1,i+1):
print()
#While a program to print the following pattern.
22
333
4444
55555
for i in range(1,6):
for j in range(1,i+1):
print()
**
***
****
*****
for i in range(1,6):
for j in range(1,i+1):
print()
#While a program to print the following pattern.
AB
ABC
ABCD
ABCDE
n=5
a = 65
a += 1
a = 65
print()
Write a program that takes a list of numbers and finds both the largest and the smallest elements in the list.
Given a list with potential duplicate values, write a program to remove the duplicates while preserving the
original order of the elements.
Write a program that checks if a given list is a palindrome (i.e., it reads the same backward as forward).
Write a program to count how many even and odd numbers are in a list of integers.
Write a program that calculates and prints the average of all the numbers in a list.
Write a program that asks the user for a number and checks if the number exists in a predefined list.