Lab-Phython Program
Lab-Phython Program
Output:
Output:
Output:
si = (p * t * r)/100
Output:
Output
Output
number = int(input ("Enter the number to print the multiplication table: "))
print ("The Multiplication Table of: ", number)
for count in range(1, 11):
print (number, 'x', count, '=', number * count)
Output
Enter the number to print the multiplication table: 13
The Multiplication Table of: 13
13 x 1 = 13
13 x 2 = 26
13 x 3 = 39
13 x 4 = 52
13 x 5 = 65
13 x 6 = 78
13 x 7 = 91
13 x 8 = 104
13 x 9 = 117
13 x 10 = 130
8. Python program to print Even Numbers in a List
print(list1)
# iterating each number in list
Output
t1 = {1,2,3,4,5,6,7,8,9,10,11,12}
print(t1)
# iterating each number in tuple
Output
# list of numbers
list1 = [10, 21, 4, 45, 66, 93, 1]
even_count, odd_count = 0, 0
# checking condition
if num % 2 == 0:
even_count += 1
else:
odd_count += 1
print(list1)
print("Even numbers in the list: ", even_count)
print("Odd numbers in the list: ", odd_count)
Output
def simple_interest(p,t,r):
print('\n')
print('The principal is', p)
print('The time period is', t)
print('The rate of interest is',r)
si = (p * t * r)/100
Output
def simple_interest(p,t,r):
si = (p * t * r)/100
print("The Simple Interest is",si)
# Driver Code
p = int(input("Enter the principal amount: "))
t = int(input("Enter rate of interest: "))
r = int(input("Enter time in years: " ))
#Function Call
simple_interest(p,t,r)
compound_interest(p,t,r)
Output
def NumberCheck(a):
if a > 0:
print("Number given by you is Positive")
elif a < 0:
print("Number given by you is Negative")
else:
print("Number given by you is zero")
Output:
def factorial(n):
return 1 if (n==1 or n==0) else n * factorial(n - 1)
# Driver Code
num = int(input("Enter the integer number "))
print("Factorial of",num,"is",factorial(num))
Output
# import module
import calendar
yy = 2023
mm = 10
Output
October 2023
Mo Tu We Th Fr Sa Su
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Output
lower = 1
upper = 40
Output
if choice == 'a':
print (num_1, " + ", num_2, " = ", add(num_1, num_2))
elif choice == 'b':
print (num_1, " - ", num_2, " = ", subtract(num_1, num_2))
elif choice == 'c':
print (num1, " * ", num2, " = ", multiply(num1, num2))
elif choice == 'd':
print (num_1, " / ", num_2, " = ", divide(num_1, num_2))
else:
print ("This is an invalid input")
output
X = [[10,20,30],
[40,50,60],
[65,70,80]]
Y = [[10,11,12],
[13,14,15],
[16,17,18]]
result = [[0,0,0],
[0,0,0],
[0,0,0]]
for i in range(len(X)):
for j in range(len(X)):
result[i][j] = X[i][j] + Y[i][j]
Output
X = [[10,20,30],[10,20,30], [10,20,30]]
Y = [[11,11,12],[13,14,15], [16,17,18]]
result = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(len(X)):
for j in range(len(X)):
result[i][j] = X[i][j] - Y[i][j]
output
sum = 0
while (n != 0):
return sum
Output
def getRev(n):
rev = 0
while(n > 0):
d = n % 10
rev = rev * 10 + d
n = n // 10
return( rev)
Output