MB
MB
MB
OUTPUT:
Enter the first no. 12
Enter the second no. 8
The sum of 12 and 8 is 20
The substraction of 12 and 8 is 4
The product of 12 and 8 is 96
5. Write a program that swaps the value of two
variables a,b without using the third variable .
OUTPUT:
Enter the first no. 12
Enter the second no. 15
'The values of variable ‘a’ before swapping are:
12
The values of variable ‘b’ before swapping are:
15
'The values of variable ‘a’ after swapping are:
15
'The values of variable ‘b’ after swapping are:
12
6. Write a program to check whether the triangle
is possible or not when three angle of triangle
are entered by the user .
OUTPUT:
OUTPUT:
Enter first point values separated by spaces =
00
Enter second point values separated by spaces =
11
Enter third point values separated by spaces=
22
The points ( 0 , 0 ) ( 1 , 1 ) ( 2 , 2 ) are collinear and lies on the straight
line
8. Write a program to find factorial of number .
OUTPUT:
OUTPUT :
Enter the number of terms you want print :
9
Fibonacci sequence:
0 1 1 2 3 5 8 13 21
if sum==num:
print('It is an Armstrong number')
else:
print('It is not an Armstrong number')
OUTPUT:
#Define a function
while temp > 0:
digit = temp % 10
sum=sum*10+digit
temp = temp//10
if sum==num:
print('It is an palindrome number')
else:
print('It is not an plindrome number')
OUTPUT:
OUTPUT:
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
14.(b) Write a program to print the patterns .
OUTPUT
*
**
***
****
*****
14.(a) Write a program to print the pattern .
OUTPUT
*****
****
***
**
*
14.(c) Write a program to print the pattern .
OUTPUT
1
12
123
1234
14.(d) Write a program to print the pattern .
OUTPUT
1
23
456
7 8 9 10
14.(e) Write a program to print the pattern .
OUTPUT
*
***
*****
*******
13. Write a program to compute the total
marks of subject and after finding the
percentage grade them accodringly .
for i in range(num_subjects):
marks = float(input(f"Enter marks for subject {i+1}: "))
total_marks += marks
percentage = (total_marks / (num_subjects * 100)) * 100
print("Value:",new_num)
print("Data Type:",type(new_num))
int_num = int(float_num)
s = integer_num + int_num
print("Value:",s)
print("Data Type:",type(s))
OUTPUT:
import math
# Calculate the square root of a number
x = 25
sqrt_x = math.sqrt(x)
print("Square root of", x, "is:", sqrt_x)
OUTPUT:
# for inf/infinity
print(float("InF"))
print(float("InFiNiTy"))
# for NaN(Not a number)
print(float("nan"))
print(float("NaN"))
# Various examples and working of complex()
# nothing is passed
z = complex()
print("complex() with no parameters:", z)
# integer type
# passing first parameter only
complex_num1 = complex(5)
print("Int: first parameter only", complex_num1)
# passing both parameters
complex_num2 = complex(7, 2)
print("Int: both parameters", complex_num2)
# float type
# passing first parameter only
complex_num3 = complex(3.6)
print("Float: first parameter only", complex_num3)
# passing both parameters
complex_num4 = complex(3.6, 8.1)
print("Float: both parameters", complex_num4)
print()
print(type(complex_num1))