Question Lab 1
1. Write a program to find the sum of two numbers.
2. Write a program to accept marks of a student in 5 subjects find
average and total
3. Write a program to accept 2 numbers and show all the mathematical
operators
4. Write a program to accept 3 numbers and show all mathematical
operations
5. Write a program to accept temperature in celsius and convert to
fahrenheit and kelvin
6. Write a program to accept Quantity and Price, find value(
Quantity*Price), Discount(15% of Value) and Net price(Value-Discount)
7. Write a program to accept 2 numbers and find larger among them
8. Write a program to accept a number and find even or odd
9. Write a program to accept a number to find negative or positive
10. Write a program to accept a number and find divisible by 7 or not
11. Write a program to accept a number and find divisible by 3 and 5 or
not
12. Write a program to accept name and marks of students in 5 subjects
find total and average and display grade
>=90 A+
<90 and >=80 A
<80 and >=70 B+
<70 and >=60 B
<60 and >=50 C+
<50 and >=40 C
<40 and >=33 D
<33 E
13. Write a program to accept Quantity and Price, find value(
Quantity*Price), Discount as
Value >=50000 (15% of Value)
Value<50000 and >=25000 10% of value
value<25000 5% of value
Also find Net price(Value-Discount)
14. Write a program to accept year and find if leap or not
15. Write a program to accept name and age of a voter and find if
eligible to vote or not
16. Write a program to accept coefficient of a quadratic equation
ax2+bx+c=0 and find its roots
17. Write a program to check whether a triangle is valid or not, when the
three angles of the triangle are entered by the user. A triangle is valid if
the sum of all the three angles is equal to 180 degrees.
18. Write a program to calculate the electricity bill (accept number of
unit from user) according to the following criteria :
Unit Price
First 100 units no charge
Next 100 units Rs 5 per unit
After 200 units Rs 10 per unit
(For example if input unit is 350 than total bill amount is Rs2000)
19. Write a program to accept 3 numbers and find largest among them
20. Write a program to accept a number and check if positive even,
negative even, positive odd and negative odd
21. Write a program to accept a number from 1 to 7 and display the name
of the day like 1 for Sunday , 2 for Monday and so on.
22. Write a program to accept a character and check if vowel or not
Answer
ch=input(“Enter Character”)
if ch in “AEIOUaeiou”:
print(“It’s a vowel”)
else:
print(“it’s not a vowel”)
23. Accept the marks of English, Math and Science, Social Studies
Subject and display the stream allotted according to following
All Subjects more than 80 marks — Science Stream
English >80 and Math, Science above 50 –Commerce Stream
English > 80 and Social studies > 80 — Humanities
24. Write a program accept the age of 4 people and display the
youngest one?
25. Write a program to accept a character and find if in upper case,
lower case, digit or special character
Answer
ch=input(“Enter Character”)
if ch in “ABCDEFGHIJKLMNOPQRSTUVWXYZ”:
print(“It’s in upper case”)
elif ch in “abcdefghijklmnopqrstuvwxyz”:
print(“it’s in lowercase”
elif ch in “0123456789”:
print(“it’s a digit”)
else:
print(“it’s a special character”)