ML Python Lab Programs
ML Python Lab Programs
print('Hello, world!')
Output
Hello, world!
num1 = 1.5
num2 = 6.3
Output
x = 5
y = 10
# To take inputs from the user
#x = input('Enter value of x: ')
#y = input('Enter value of y: ')
Output
while num != 0:
digit = num % 10
reversed_num = reversed_num * 10 + digit
num //= 10
factorial = 1
Output
Output 1
Enter a number: 43
43 is Odd
Output 2
Enter a number: 18
18 is Even
# Python program to check if the number is an
Armstrong number or not
# initialize sum
sum = 0
Output 1
Enter a number: 663
663 is not an Armstrong number
Output 2
num = 16
if num < 0:
print("Enter a positive number")
else:
sum = 0
# use while loop to iterate until zero
while(num > 0):
sum += num
num -= 1
print("The sum is", sum)
Output
my_str = 'aIbohPhoBiA'
Output
Output
Output
# string of vowels
vowels = 'aeiou'
print(count)
Output
prime_numbers = [11, 3, 7, 5, 2]
print(prime_numbers)
sorted_numbers = sorted(numbers)
print(sorted_numbers)
output:
2*10=20 2*5=10
2*9=18 2*4=8
2*8=16 2*3=6
2*7=14 2*2=4
2*6=12