Ip Practical File
Ip Practical File
PRACTICAL FILE
CODE-065
Output:
if operator == '+':
print(f"The result is {num1 + num2}")
elif operator == '-':
print(f"The result is {num1 - num2}")
6
Output:
if gender.upper() == 'M':
title = "Mr."
else:
title = "Ms."
print(f"Hello, {title} {firstname} {lastname} Welcome!! Hope You
like this program")
Output:
total_marks = sum(marks)
percentage = (total_marks / 500) * 100
grade = "B2"
elif percentage >= 50:
grade = "C1"
elif percentage >= 40:
grade = "C2"
elif percentage >= 33:
grade = "D"
else:
grade = "E"
Output:
else:
print(f"The last digit {last_digit} is not divisible by 3.")
Output:
Enter a number: 19
The last digit 9 is divisible by 3.
Output:
Output:
Enter an alphabet: l
l is not a vowel.
Output:
Output:
10. WAP to accept three numbers and find the largest of them.
Output:
11. WAP to accept the three sides of a triangle and find if given
triangle dimensions make a Pythagoras triangle.
Output:
Output:
Output:
Enter a number: 10
Enter the last number: 2
10 x 1 = 10
10 x 2 = 20
14. Write a menu driven program that gives the choice to the
user to find the sum of any of the following series: (i)
1+2+3+....... +N (ii) 1+3+5+....... +N
15
Output:
15. WAP to compute the sum of the following series: 2^2 + 4^2 +
6^2 + ....... +N^2
16
Output:
16. WAP to accept the starting no., ending no., difference in terms of
series, and display the series as well as the sum of the series.
Output:
6
8
10
17. WAP to find factors of a given number and also find if the given
no. is a perfect no. A perfect no’s sum of factors excluding itself is
equal to the number e.g. 6 (factors 1+2+3 = 6 which is the same as
6).
Output:
Enter a number: 10
10 is not a perfect number.
18. WAP to accept the base and exponent and find the power.
i += 1
print(f"{base} ^ {exponent} = {result}")
Output:
Output:
Enter a number: 9
Factorial of 9 is 362880
20. WAP to find the sum of the following series: 1/1 + 1/2 + 1/3 +
1/4 + ............... 1/N
sum_series += 1 / i
i += 1
print(f"Sum of the series 1/1 + 1/2 + 1/3 + ... + 1/{N} is {sum_series:}")
Output:
Output:
Output:
Thank you