- Write a program to find the sum of numbers in given string?
Sample input:
sentence = "Python Programming training on 05 dec 2020 to 26 dec 2020"
Sample output:
Sum of numbers in a given string is 21
- Write a program to find factorial of given input number from the user?
- Sample input1:
number = 5
Sample output1:
Factorial of 5 is 120
- Sample input2:
number = 4
Sample output2:
Factorial of 4 is 24
- Write a program to find the lucky number from given mobile numer lucky number means reduce the sum of digits to single digit(0 between 9)
Sample input:
mobile = "9848022338"
Sample output:
Lucky number is 2
#explanation: 9+8+4+0+2+2+3+3+8 = 47 -> 11 -> 2 (lucky number 2)
- Write a program to find the sum of squares of even numbers in given string
Sample input:
string = '123@psw456'
Sample output:
Sum of the squares of the even numbers in the string is 56
- Write a program to find how many number of unique characters in given name
Sample input1:
input = python
Sample output1:
Unique characters in the string is 6
Sample input2:
input = pythonprogramming
Sample output2:
Unique characters in the string is 11
- Check the string is Palindrome or not
Sample input1:
121
Sample output1:
Given String 121 is Palindrome
Sample input2:
ababa
Sample output2:
Given String ababa is Palindrome
- Write a program to swap the 2 characters in a string Sample input:
Python
Sample output:
yphtno
- Write a Python program to get a string made of the first 2 and the last 2 chars from a given string. If the string length is less than 2, return instead of the empty string.
Sample input1:
'python'
Sample output1:
'pyon'
Sample input2:
'py'
Sample output2:
'pypy'
Sample input3:
'p'
Sample output3:
'p'
- Write a Python program to change a given string to a new string where the first and last chars have been exchanged. Sample input:
Python
Sample output:
nythop
- Check the given number is Armstrong number or not Method 1: Sample input:
Input: 153 or 1634
Sample output:
Armstrong Number of 1634 is 1634
# Explanination: 1^3+5^3+3^3 = 153 or 1^4+6^4+3^4+4^4 = 1634
Method 2 Sample input:
No of digits - 3
n = 153
Sample output:
Armstrong Number of 153 is 153
# Explanination 1^3+5^3+3^3 = 153