Professional Documents
Culture Documents
Python Questions
Python Questions
1.Write a python program to convert a decimal number into binary and octal number.
print(bin(decNum)[2:])
print(bin(decNum)[2:])
print(oct(decNum))
2.Write a program to add elements dynamically asked from user how many no enter in a list.
3.Write a program to find the sum of all elements in a list and a tuple.
re=0
list2=[1,2,3,4]
re=re+list2[i]
print(re)
4.Write a program to take a number from user and print all palindrome number till that number.
ju=int(input("enter range"))
rev=0
temp=i
while temp>0:
digit=temp%10
rev=(rev*10)+digit
temp=temp//10
if(i==rev):
print(i)
6.Write a program to take character as input if character is in lowercase convert it into uppercase and
viceversa.
Company decide to give bonus to all its employees on diwali. If 5% bonus on salary is given to male
employee and 10% is given to female employee. Take salary & gender as input. If sal<10,000 then
employee gets an extra 2% bonus. Calculate the bonus to be given to employee and display the salary.
If average>=90:
Print(“Excellent”)
Print(“very good”)
Print(“good”)
Print(“good”)
Print(“average”)
Else:
Print(“failllll”)
11. Write a program to find out whether a number is even or odd. Also check it is +vie or –vie number.
12.Write a program to check whether the given year is leap year or not.
s="ana"
s1=""
temp=""
temp=s
for i in s:
s1=i+s1
print(s1)
if(temp==s1):
print("palindrome")
else:
print("not palindrome")
15. Write a program to to take a string from user and find total no of words in a string and reverse each
word and store into a new string.
16.Write a program to find a square of a number taken as input from the user. The number will be asked
repeatedly till user enters 0(zero).
17.Write a program to create heterogeneous list and store string in another list similarly integer and
float number also store separately in lists.(using for loop)
Ex:- 2*1=2
20.Write a program to find out all the string in a list and store them in new list.