0% found this document useful (0 votes)
1 views

1. Python Sheets

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

1. Python Sheets

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PYTHON PRACTICE SHEET

Q1. Check the output of the following question:


str='s'
if(str.islower()):
print(str.upper())
elif(str.isupper()):
print(str.lower())
Q2. Write a program to input a digit (0 – 9) and print the number names.
Q3. Check the output of the following question:
tc=input("enter the total cost of items ")
dis=0
if(tc<=2000):
dis=tc*5/100
elif(tc>=2001 and tc<=5000):
dis=tc*25/100
elif(tc>=5001 and tc<=15000):
dis=tc*35/100
elif(tc>=15001):
dis=tc*50/100
print("Cost after discount is",tc-dis)
Q4. Check the output of the following question:
marks=input("Enter your total marks out of 500 ")
if(marks>=400):
print"SCIENCE Stream"
elif(marks>=250 and marks<=399):
print"COMMERCE Stream"
elif(marks>=165 and marks<=249):
print"HUMANIITES Stream"
elif(marks>=0 and marks<=164):
print"No Stream"
Q5. Write a program to compute salesman commission on the following basis:
Sales (Rs.) Commission
1 – 100000 15%
100001 – 200000 25%
Above 200000 45%
Q6. Write a program with three integer values as a three sides of a triangle and decide whether it is a scalene, isosceles
or equilateral triangle.
Q7. An employee is entitled to pay an income tax based on his gross annual income as per the given rule:
Gross annual income (Rs.) Annual tax deduction
Less than or equal to 100000 NIL
100001 to 150000 10% of the income exceeding 100000
150001 to 200000 5000 + 20% of the income exceeding 150000
Above 200000 15000 + 30% of the income exceeding 200000
Write a program to input gross annual income and print the payable income tax by the employee.
Q8. A Library charges a fine for books returned late. Following are the fines:
First Five Days: 40 paise per day
Six to Ten Days: 65 paise per day
Above Ten days: 100 paise per day
Write a program which takes as input the number of days late and prints the fine.
Q9. The telephone department wishes to compute monthly telephone bills for its customers using the following rules on
the basis of call made:
Number of calls Rate
First 80 calls Rs. 250/-
Next 80 Calls 60 paisa per call
Next 160 Calls 50 paisa per call
Any call above 280 Calls 40 paisa per call
Write a program to input number of calls and compute total bill amount.
Q10. Write a program to calculate and print roots of a quadratic equation ax2 + bx + c = 0 (a!=0)with appropriate
messages the root are given by:
−b ± √ b2 −4 ac
x 1∧x 2=
2a
If b2 – 4ac > 0 then roots are real and unequal.
If b2 – 4ac = 0 then roots are real and equal.
If b2 – 4ac < 0 then roots are imaginary.
Q11. Write a program to convert a given temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice,
an appropriate message should be displayed. C= 5/9 x (F-32) , F = 1.8 x (C + 32)
Q12. Check the output of the following question:
v1=input("Enter your first integer value")
v2=input("Enter your second integer value")
v3=input("Enter your third integer value")
if(v1>v2 and v1>v3):
print"Vlaue of ",v1," is greater"
elif(v2>v1 and v2>v3):
print"Vlaue of ",v2," is greater"
elif(v3>v1 and v3>v2):
print"Vlaue of ",v3," is greater"
Q13. Write a program to input 3 integers and find the lowest from them.
Q14. Write a program to input a number (between 1 – 12) print the name of month using the number.
Q15. Write a program to input a number (between 1 – 7) print the name of week using the number.
Q16. Write a program to print the various designations on the basis of the first letter given as input. The designations are
limited in the process as given: Manager, Producer, Charted Accountant, Engineer, Officer and Teacher. Input a
character (in capital or small) and print the corresponding designation.
Input: M Output: Manager
Q17. Write a program to input a two digit number (your program should display a message if the number is not having
two digits). Split both the digits of that number and print the corresponding number name for each digit. Input: 46
Output: Four Six / SIX FOUR
Q18. Check the output of the following question:
x="abcdef"
i="a"
while i in x:
print i,
Q19. Check the output of the following question:
num=1
sumeven=0
sumodd=0
while(num<=100):
if(num%2==0):
sumeven=sumeven+num
else:
sumodd=sumodd+num
num=num+1
print("Sum of Even numbers between 1 to 100 is ",sumeven)
print("Sum of Odd numbers between 1 to 100 is ",sumodd)
Q20. Check the output of the following question:
num=input("Enter any number")
m=1
while(m<=20):
print num," * ",m," = ",num*m
m=m+1
Q21. Check the output of the following question:
m=1
while(m<=255):
print m,' = ',chr(m)
m=m+1
Q22. Check the output of the following question:
m=0
while(m<10):
print m,' = ',ord(str(m))
m=m+1
Q23. Check the output of the following question:
num=input("Enter any number here")
f=1;
while(num>0):
f=f*num
num=num-1
print "Factorial is = ",f
Q24. Check the output of the following question:
num=input("Enter any number here")
s=0;
r=0
while(num>0):
r=num%10
s=s*10+r
num=num/10
print "Reverse of given number is = ",s
Q25. Check the output of the following question:
num=input("Enter any number here")
s=0;
r=0
while(num>0):
r=num%10
s=s+r
num=num/10
print "Sum of digit of given number is = ",s
Q26. Check the output of the following question:
num=input("Enter any number here")
s=1;
print "Factors of given number is ",
while(s<=num):
if(num%s==0):
print s,
s=s+1
Q27. Check the output of the following question:
num=input("Enter any number here")
s=1;
r=0
while(s<=num):
if(num%s==0):
r=r+s
s=s+1
print(“Sum of the Factors of given number is ”, r)
Q28. Check the output of the following question:
num=input("Enter any number here")
n=num
s=0;
r=0
while(num>0):
r=num%10
s=s*10+r
num=num/10
if(n==s):
print"Given number is PALINDROME number"
else:
print"Given number is not a PALINDROME number"
Q29. Check the output of the following question:
num=input("Enter any number here")
n=num
s=0;
r=0
while(num>0):
r=num%10
s=s+(r*r*r)
num=num/10
if(n==s):
print"Given number is ARMSTRONG number"
else:
print"Given number is not a ARMSTRONG number"
Q30. Write a program to input an integer. Print the Product of the first and last digit of the integer. (Ex: Input: 2354
Output: 8, Input: 682354 Output: 24)
Q31. Write a program to input a number and check whether it is a Prime number or not.
Q32. Write a program to input a number and check whether it is a Perfect number or not. (Ex. 6 = 2x6 = 1+2+3+6)
Q33. Write a program to input a number and check whether it is a Special number or not. (Ex. 145 =1! + 4! + 5!)
Q34. Write a program to input a number and check whether it is an Automorphic number or not. (Ex. 5= 25, 25 = 625)
Q35. Write a program to input an integer number and check whether it is a Buzz number or not. (Number which either
ends with 7 or divisible by 7)
Q36. Write a program to input two integers and print their LCM.
Q37. Write a program to input two integers and print their HCF.
Q38. Write a program to input a number and print sum of all the digits and count of all the digits. Input: 5623 Output:
Count = 4, Sum = 16
Q39. Write a program to input a number and check whether it is a Neon number or not. (Ex. 9 = 9x9 = 81, 8+1=9)
Q40. Check the output of the following question:
1. for a in range(1,6):
for b in range(a,6):
print(b),
print
2. for a in range(2,6):
for b in range(1,a):
print(b),
print
3. for a in range(6,0,-1):
for b in range(1,a):
print(b),
print
4. for a in range(5,-1,-1):
for b in range(a,0,-1):
print(b),
print
5. for a in range(5,-1,-1):
for b in range(a,0,-1):
print(a),
print
6. for a in range(6,0,-1):
for b in range(1,a):
print(a),
print
7. for a in range(2,6):
for b in range(1,a):
print(a),
print
8. for a in range(1,6):
for b in range(a,6):
print(b),
print
9. for a in range(1,5):
for b in range(1,5):
print(a*b),
print
10. for a in range(1,6):
c=a
while(c>1):
print " ",
c=c-1
for b in range(a,6):
print(b),
print
11. for a in range(65,70):
c=a
while(c>65):
print " ",
c=c-1
for b in range(a,70):
print(chr(b)),
print
12. d=10
for a in range(1,5):
c=a
while(c>1):
print " ",
c=c-1
for b in range(a,5):
print(d),
d=d-1
print

You might also like