Professional Documents
Culture Documents
2561746_Technical Assignment
2561746_Technical Assignment
1. Program to display the sum of digits in a number. Eg: for input 234, result is 2+3+4 = 9.
a=int(input()) 123
b=0
while(a>0):
b+=a%10
a=a//10
print(b)
6. Input temperature for a week. Calculate the average temperature and display the
highest and lowest temperature using functions.
n=int(input())
a=list(map(int, input().split()))[:n]
c=0
for i in range(len(a)):
c+=a[i]
d=c/n
print("Average temperature is " + str(d))
max = a[0];
for i in range(0, len(a)):
if(a[i] > max):
max = a[i];
print("Highest temperature is " + str(max));
l = a[0]
for i in range(0,len(a)):
if (a[i] < l):
l=i
print("Lowest temperature is " + str(l))
8. Calculate the income tax to be paid by an employee as per the criteria given below:
Slab rate IT rate
Upto Rs. 50,000 Nil
Upto Rs. 60,000 10% on additional amount
Upto Rs. 1,50,000 20% on additional amount
Above Rs. 1,50,000 30% on additional amount
9.Calculate grade and Display the Remarks of a student. Consider score of 5 subjects.
Calculate the percentage and grade as per the criteria below: [Hint: use Switch case]
Percentage Grade Remark
>95% A Excellent
>75% B Good
>50% C Well done
>40% D Passed
<40% E Failed
scores = []
for i in range(5):
score = float(input(f"Enter score {i+1}: "))
scores.append(score)
total_score = sum(scores)
percentage = (total_score / (5 * 100)) * 100
remarks = {
'A': 'Excellent',
'B': 'Good',
'C': 'Well done',
'D': 'Passed',
'E': 'Failed'
}
grade = ''
if percentage > 95:
grade = 'A'
elif percentage > 75:
grade = 'B'
elif percentage > 50:
grade = 'C'
elif percentage > 40:
grade = 'D'
else:
grade = 'E'
print("Percentage:", round(percentage,2))
print("Grade:",grade)
print("Remark:", remarks[grade])
10. Program to create a calculator which does basic mathematic operations (addition,
subtraction, multiplication and division) using function call for 2 input values
def addition(x, y):
return x + y
print("Select operation:")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
if i == '1':
print("Result:", addition(num1, num2))
elif i == '2':
print("Result:", subtraction(num1, num2))
elif i == '3':
print("Result:", multiplication(num1, num2))
elif i == '4':
print("Result:", division(num1, num2))
else:
print("Invalid input")