0% found this document useful (0 votes)
53 views3 pages

Python Questions

The document contains 20 Python programming questions related to various topics like data types, conditional statements, loops, functions, strings, lists, tuples etc. Some of the questions involve taking input from the user, performing calculations and printing output. The questions cover basic to intermediate level Python concepts.

Uploaded by

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

Python Questions

The document contains 20 Python programming questions related to various topics like data types, conditional statements, loops, functions, strings, lists, tuples etc. Some of the questions involve taking input from the user, performing calculations and printing output. The questions cover basic to intermediate level Python concepts.

Uploaded by

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

PYTHON QUESTIONS:-

1.Write a python program to convert a decimal number into binary and octal number.

decNum = int(input("Enter any Decimal Number: "))

print(bin(decNum)[2:])

print(oct(decNum)) decNum = int(input("Enter any Decimal Number: "))

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]

for i in range (0,len(list2)):

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"))

for i in range (0,ju+1):

rev=0

temp=i

while temp>0:

digit=temp%10

rev=(rev*10)+digit

temp=temp//10

if(i==rev):
print(i)

5.Write a program to calculate salary of an employee given his basic pay(input) .

HRA=10% OF Basic salary

TA=5% of basic salary

Based on it calculate salary of an employee

6.Write a program to take character as input if character is in lowercase convert it into uppercase and
viceversa.

7.Write a program for the following case study:-

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.

8.Write a program to calculate factorial of a given number.

9. Write a program to take a number from user and reverse it.

10.Write a program to calculate a result of student based on performance of marks in 5 subjects.

If average>=90:

Print(“Excellent”)

Elif(avg<90 and avg>=80):

Print(“very good”)

Elif(avg<80 and avg>=70):

Print(“good”)

Elif(avg<70 and avg>=60 ):

Print(“good”)

Elif(avg<60 and avg>=40):

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.

13.Write a program to reverse a string and find it is palindrome 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")

14.Write a program to find count of vowels, consonants and special characters.

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)

18.Write a program to sort the data in a list.

19.Write a program to display table of a number(input from user) in a given format:-

Ex:- 2*1=2

20.Write a program to find out all the string in a list and store them in new list.

You might also like