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

Technical Assignment

Uploaded by

Pavan Yoyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Technical Assignment

Uploaded by

Pavan Yoyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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)

2. Write a program to find the factorial of a number.


a=int(input())
b=1
for i in range(1,a+1):
b=b*i
print(b)

3. Program to find the palindrome of a number


a=int(input())
d=a
c=0
while(a>0):
b=a%10
c=c*10+b
a=a//10
if(d==c):
print("The number is palindrome")
else:
print("Not a palindrome")
4. Write a program to input n numbers using array and find the greatest number of them.
n=int(input())
arr=list(map(int, input().split()))[:n]
max = arr[0];
for i in range(0, len(arr)):
if(arr[i] > max):
max = arr[i];
print("Largest element is " + str(max));

5. Write a program to print the following pattern given n as argument:


[for input 3]
1
22
333
r=int(input())
for i in range(r+1):
for j in range(i):
print(i, end=' ')
print('')

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))

7. Multiplication table (first 10) of the number you provide.


n=int(input())
for i in range(1,11):
print(n,"x",i,"=",n*i)

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

income = float(input("Enter the income: "))


if income <= 50000:
tax = "Nil"
elif income <= 60000:
tax = (income - 50000) * 0.10
elif income <= 150000:
tax = (60000 - 50000) * 0.10 + (income - 60000) * 0.20
else:
tax = (60000 - 50000) * 0.10 + (150000 - 60000) * 0.20 + (income - 150000) * 0.30
print("Income tax to be paid:", tax)

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

def subtraction(x, y):


return x - y

def multiplication(x, y):


return x * y

def division(x, y):


if y == 0:
return "Not divisible by zero"
else:
return x / y

print("Select operation:")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")

i = input("Enter choice (1/2/3/4): ")

if i in ('1', '2', '3', '4'):


num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

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")

You might also like