1.Read a number form keyboard, if it is negative print “you have entered a negative number".
a = int(input("Enter any Number :"))
if a < 0:
print("You have entered a negative number")
##else case no needed.
##else:
## print("You have entered a positive number")


2. Ready any string from console/keyboard, if it is rgukt then print it twice.
a = input("Enter any string :")
if a == "rgukt":
print(a*2)
else:
print(a)


3. Read any two numbers from console and find the smallest.
a =int(input("Enter any Number :"))
b =int(input("Enter any Number :"))
##Modal 1
if a < b :
print("The smallest number is",a)
else:
print("The smallest number is",b)
##Modal 2
##print("The smallest number is",min(a,b))


4. Read any two strings and verify whether they are equal or not.
a = input("Enter any String :")
b = input("Enter any String :")
if a == b :
print("Both Strings are Equal.")
else:
print("Both Strings are not Equal.")


5.Check a person is eligible for voting or not.
a = int(input("Enter your Age :"))
if a >= 18:
print("Eligible for Voting")
else:
print("Not Eligible for Voting")


6.Check a students is PUC-1 or PUC-2 based on his ID number. (input must be first 3 characters of students ID)
a = input("Enter first three characters of your ID")
if a == "s20":
print("your PUC-2 student")
elif a == "s21":
print("your PUC-1 student")
else:
print("invalid input")


7.Read a string and verify whether it is saturday or sunday.
a = input("Enter any Day :")
if a == "sunday":
print("Sunday")
elif a == "saturday":
print("Saturday")
else:
print(a)


8. Check a number is even or odd.
a = int(input("Enter any Number"))
if a % 2 == 0:
print("Even Number")
else:
print("Odd Number")


9. Check a year is leap year or not(Normal years only).
a = int(input("enter year"))
if a%4 == 0:
print("Leap year")
else:
print("Not a leap year")


10. Read any character from keyboard and verify whether it is a vowel or any other character.
a = input("Enter any character")
if a = "a" or a == "e" or a == "i" or a == "o" or a == "u":
print("Vowel")
else:
print("Other character")


11. Verify profit or loss based on CP and SP
a = int(input("Enter cost prize :"))
b = int(input("Enter selling prize :"))
if a > b:
print("Loss")
elif a < b:
print("Profit")
else:
print("No profit / No loss")


12. Check a number is divisible by 11 or not.
a = int(input("Enter any Number :"))
if a%11 == 0:
print("It is divisible by 11")
else:
print("It is not divisible by 11")


13. Read any 3 subject marks(Out of 100), and display which result user wants.
a = int(input())
b = int(input())
c = int(input())
print("1.Total","2.Average","3.Percentage")
d = int(input())
if d == 1:
print(a+b+c)
elif d == 2:
print((a+b+c)/3)
elif d == 3:
print(((a+b+c)/3)*100)
else:
print("invalid input")


14. Verify a triangle is valid or not based on sides (any two sides sum must be greater than third side).
a = int(input())
b = int(input())
c = int(input())
if a+b > c or a+c > b or b+c > a:
print("Valid Triangle")
else:
print("Invalid Triangle")


15. Read 3 angles of a triangle and verify whether it is a valid triangle or not.
a = int(input())
b = int(input())
c = int(input())
if a+b+c == 180 and a != 0 and b != 0 and c != 0:
print("Valid Triangle")
else:
print("Invalid Triangle")


16. Verify a triangle is equilateral or isosceles or scalene.
a = int(input())
b = int(input())
c = int(input())
if a+b+c == 180 and 0 < a < 180 and 0 < b < 180 and 0 < c < 180:
if a == b == c:
print("Equilateral Triangle")
elif a == b or a == c or b == c:
print("Isosceles Triangle")
else:
print("Scalene Triangle")
else:
print("Invalid triangle")


17. Read any three numbers and find the largest.
a = int(input())
b = int(input())
c = int(input())
if a == b == c:
print("Three numbers are equal.")
elif a == b:
if a > c:
print(a,b,"are greater numbers")
else:
print(c, "is greater number")
elif a == c:
if a > b:
print(a,c,"are greater numbers")
else:
print(b,"is greater number")
elif b == c:
if b > a:
print(b,c,"are greater numbers")
else:
print(a,"is greater")
else:
if a > b and a > c:
print(a,"is greater")
elif b > a and b > c:
print(b,"is greater")
else:
print(c,"is greater")


18. Read any two numbers and an arithmetic operator, based on the input operator display the result.
a = int(input())
b = int(input())
c = input()
if c == "+":
print(a+b)
elif c == "-":
print(a-b)
elif c == "x" or c == "*":
print(a*b)
elif c == "/" or c == "//":
print(a//b)
else:
print("Invalid input")


19. Read any subject marks and find grade.A grade(80-100),B grade(60-79),C grade(40-59),Fail(0-39)and invalid input(<0 and >100)
a = int(input())
if 100 >= a >= 80:
print("A grade")
elif 79 >= a >= 60:
print("B grade")
elif 59 >= a >= 40:
print("C grade")
elif 39 >= a >= 0:
print("Fail")
else:
print("Invalid input")


20. Read any string triangle/square/rectangle based on the input display the area.
a = input("enter any string(triangle,square,rectangle)")
if a == "triangle":
b = int(input("Enter base of the triangle"))
c = int(input("Enter height of the triangle"))
print((1/2)*b*c)
elif a == "square":
b = int(input("Enter side of the square."))
print(b*b)
elif a == "rectangle":
b = int(input("Enter lenght of the rectangle"))
c = int(input("Enter width of the rectangle"))
print(b*c)
else:
print("Invalid Input")


21. Read any two digit numbers and print its difference with 100, if the entered number is equal to 10 then double the difference.
a = int(input())
if 9 < a < 100:
if a == 10:
print((100-a)*2)
else:
print(100-a)
else:
print("Please enter a two digit number")


22. Read any number from 1-7 and its day name according to it.(1-sunday, 2-monday, 3-tuesday…...7-saturday)
a = int(input())
## Modal 1
if a == 1:
print("1.sunday")
elif a == 2:
print("2.monday")
elif a == 3:
print("3.tuesday")
elif a == 4:
print("4.wednesday")
elif a == 5:
print("5.thursday")
elif a == 6:
print("6.friday")
elif a == 7:
print("7.saturday")
else:
print("Enter any number only between 1 to 7.")
## Modal 2
b = ["1.sunday","2.monday","3.tuesday","4.wednesday","5.thursday","6.friday","7.saturday"]
if 1 <= a <= 7:
print(b[a-1])
else:
print("Enter any number only between 1 to 7.")


23. Read any two numbers, print “hello” if their difference is 0 or any of the numbers is 0.
a = int(input())
b = int(input())
if a-b == 0 or a == b:
print("hello")
elif a == 0 or b == 0:
print("hello")
else:
print("Try again")


24. Read any three numbers and print their sum, if any of the numbers is 13 then treat it as zero.
a = int(input())
b = int(input())
c = int(input())
if a == 13 and b == 13 and c == 13:
print(0)
elif a == 13 and b == 13:
print(c)
elif a == 13 and c == 13:
print(b)
elif b == 13 and c == 13:
print(a)
elif a == 13:
print(b+c)
elif b == 13:
print(c+a)
elif c == 13:
print(a+b)
else:
print(a+b+c)


25. Read any 3 numbers, print their sum, if one of the values is the same as another of the values, it must be ignore.
a = int(input())
b = int(input())
c = int(input())
if a == b == c:
print(0)
elif a == b:
print(c)
elif a == c:
print(b)
elif b == c:
print(a)
else:
print(a+b+c)


26. Read any three numbers say a,b,c.if a is equal to 7 then output is 0.if b is equal to 7 then output is a.if c is equal to 7 then output is a+b.if a,b,c is NOT Equals to 7 then output is a+b+c
a = int(input())
b = int(input())
c = int(input())
if a == 7 and b == 7 and c == 7:
print(7+(a+b))
elif a == 7:
print(0)
elif b == 7:
print(a)
elif c == 7:
print(a+b)
else:
print(a+b+c)


27. Dvelop Python Code to find roots of quadratic equation and check real/imaginary/equal roots.
a = float(input())
b = float(input())
c = float(input())
d = ((-b)+((b*2)-4*a*c)(1/2))/2*a
e = ((-b)-((b2)-4*a*c)(1/2))/2*a
if ((b2)-4*a*c) > 1:
print("Real roots",d,",",e)
elif ((b2)-4*a*c) == 0:
print("Equal roots",d,",",e)
elif ((b*2)-4*a*c) < 1:
print("Imaginary roots",d,",",e)


28. A male person will get 20% bonus on his salary and female person will get 30% bonus on his salary. Print the final amount they get after adding bonus to their salary.
a = int(input())
b = input("male or female :")
if b == "male":
print(((20/100)*a)+a)
elif b == "female":
print(((30/100)*a)+a)
else:
print("Invalid input")


29. Calulate how much tax a person will pay based on given conditions. If income up to 1 Lakh then tax payable is 10%, if income is 1 Lakh to 2.5 lakh then tax payable is 20%, if income above 2.5 Lakh then tax payable is 30%.
a = int(input())
if a <= 100000:
print("your tax payable is 10%",(10/100)*a)
elif 250000 >= a > 100000:
print("your tax payable is 20%",(20/100)*a)
elif a > 250000:
print("your tax payable is 30%",(30/100)*a)
else:
print("invlaid input")


*Questions Prepared by--Srikanth.D

Mentor in IT,Dept of IT,RGUKT-SRIKAKULAM
duppada8@rguktsklm.ac.in



29

Projects

300

Minutes Of Support

5

Hard Worker