22bsit113 (Ass-1) Copy
22bsit113 (Ass-1) Copy
Assigment-1
22bsit113
1) Write a python code to input age and check for eligibility of voting and create various
test cases.
Code :-
def check_voting_eligibility(age):
if age < 0:
else:
try:
print(check_voting_eligibility(user_age))
except ValueError:
TC001 10 NO
TC002 19 YES
TC003 40 YES
TC004 -9 INVALID
TC005 78 YES
Software Testing
Assigment-1
22bsit113
TC006 4 NO
TC007 14 NO
of units purchased:
Write test cases using Equivalence Partitioning (EP) and Boundary Value
22bsit113
A bank offers personal loans based on the credit score and monthly salary of an
applicant.
22bsit113
- Credit Score 600 - 749 and Salary 30,000 - 49,999 → Loan Partially
Approved
Write test cases using Equivalence Partitioning (EP) and Boundary Value
Analysis (BVA).
Code :-
elif 600 <= credit_score < 750 and 30000 <= salary < 50000:
else:
try:
print(check_loan_eligibility(credit_score, salary))
except ValueError:
22bsit113
TC002 100000 800 Loan Approved
4) An e-commerce website provides the following discount rules based on cart value
and membership:
Write test cases using Equivalence Partitioning (EP) and Boundary Value
Analysis (BVA).
Code:-
return 0 # No Discount
return 5 # 5% Discount
22bsit113
elif cart_value >= 10000 and membership.lower() == 'prime':
else:
try:
except ValueError:
22bsit113
5)Write a Python code that takes a student’s marks in different subjects, calculates
the total, percentage, and grade, and then determines whether the student has
passed or failed. Create test cases for Equivalence Partitioning (EP) and Boundary Value
Analysis (BVA).
CODE :-
def calculate_result(marks):
total_marks = sum(marks)
grade = 'A'
grade = 'B'
grade = 'C'
else:
grade = 'F'
22bsit113
try:
marks = []
for i in range(num_subjects):
marks.append(mark)
print(f"Percentage: {percentage:.2f}%")
print(f"Grade: {grade}")
print(f"Status: {status}")
except ValueError:
TC003 4 INVALID
INPUT(BECAUSE I
HAVE PUT
INTEGER)
22bsit113
TC005 4 35% F-FAIL
6)CODE:-
def calculate_bill(units):
else:
return amount
try:
22bsit113
units_consumed = int(input("Enter power consumed (in units): "))
bill_amount = calculate_bill(units_consumed)
print("\nElectricity Bill")
print("------------------------------")
print("------------------------------")
except ValueError:
If the basic salary of a worker is less than Rs. 2,500/- per month, her overtime
allowance is Rs.10/- per hour for the first 10 hours and Rs. 7.50 per hour for hours
22bsit113
excess of Rs. 2,500/- per month but less than 3,500/- per month, the overtime
allowance is Rs. 15/- per hour for the first 10 hours, and Rs. 10 per hour for hours
in excess of 10, up to a maximum of Rs. 1250/- per month. If the basic salary is in
excess of Rs. 3,500/- per month, the overtime allowance is Rs. 20/- per hour for the
first 10 hours and Rs. 15 per hour for hours in excess of 10, up to a maximum of
CODE:-
rate_first_10 = 10
rate_excess = 7.50
max_overtime = 750
rate_first_10 = 15
rate_excess = 10
max_overtime = 1250
else:
rate_first_10 = 20
rate_excess = 15
max_overtime = 1500
22bsit113
overtime_pay = overtime_hours * rate_first_10
else:
return overtime_pay
try:
print("----------------------------------")
print("----------------------------------")
except ValueError:
22bsit113
SALARY HOURS PAY OUTPUT OUPUT
OUTPUT