LCM of Two Numbers
LCM (Least Common Multiple) of two given numbers without using built-in math functions or user-defined functions.
Output of program
Enter first number: 5
Enter second number: 7
LCM of 5 and 7 is 35
LCM (Least Common Multiple) of two given numbers without using built-in math functions or user-defined functions.
Output of program
Enter first number: 5
Enter second number: 7
LCM of 5 and 7 is 35
Following python program will generate 100 random numbers between 1 to 100.
Output
Generated 100 random numbers in range 1 to 100:
[31, 48, 64, 37, 69, 53, 75, 24, 34, 19, 5, 2, 44, 12, 51, 96, 49, 92, 54, 99, 78, 68, 87, 74, 92, 53, 68, 41, 76, 13, 59, 89, 52, 99, 17, 41, 37, 43, 47, 32, 13, 10, 91, 87, 46, 3, 29, 46, 11, 71, 74, 26, 21, 63, 67, 80, 10, 33, 4, 4, 30, 89, 63, 93, 90, 24, 2, 46, 73, 91, 88, 94, 5, 93, 18, 5, 31, 93, 66, 54, 28, 8, 11, 39, 17, 96, 91, 60, 38, 4, 77, 98, 7, 45, 48, 64, 51, 40, 38, 34]
* * *
Expected Output: If user enters string = Hello Students, output should be
Total Number of Characters in a String = 14
Program Code:
# Python program to count total number of characters in a given String str1 = input("Enter your string: ") count = 0 #initialize counter to 0 for i in str1: count = count + 1 print("Total Number of Characters in a String = ", count)
Output of Program:
Enter your string: Hello Students Total Number of Characters in a String = 14
* * * * *